コード例 #1
0
  @Test
  public void shouldDetectCsv() {
    final SopremoPlan actualPlan =
        parseScript(
            "$input = read from 'file://input.csv';\n" + "write $input to 'file://output.json';");

    final SopremoPlan expectedPlan = new SopremoPlan();
    final Source input = new Source(new CsvFormat(), "file://input.csv");
    final Sink output = new Sink("file://output.json").withInputs(input);
    expectedPlan.setSinks(output);

    assertPlanEquals(expectedPlan, actualPlan);
  }
コード例 #2
0
  @Test
  public void shouldConfigureQuotationOn() {
    final SopremoPlan actualPlan =
        parseScript(
            "$input = read csv from 'file://input.any'"
                + "  quote true;\n"
                + "write $input to 'file://output.json';");

    final SopremoPlan expectedPlan = new SopremoPlan();
    final Source input = new Source(new CsvFormat().withQuotation(true), "file://input.any");
    final Sink output = new Sink("file://output.json").withInputs(input);
    expectedPlan.setSinks(output);

    assertPlanEquals(expectedPlan, actualPlan);
  }
コード例 #3
0
  @Test
  public void shouldConfigureEncoding() {
    final SopremoPlan actualPlan =
        parseScript(
            "$input = read csv from 'file://input.any'"
                + "  encoding 'iso-8859-1';\n"
                + "write $input to 'file://output.json';");

    final SopremoPlan expectedPlan = new SopremoPlan();
    final Source input = new Source(new CsvFormat().withEncoding("iso-8859-1"), "file://input.any");
    final Sink output = new Sink("file://output.json").withInputs(input);
    expectedPlan.setSinks(output);

    assertPlanEquals(expectedPlan, actualPlan);
  }
コード例 #4
0
  @Test
  public void shouldConfigureColumnNames() {
    final SopremoPlan actualPlan =
        parseScript(
            "$input = read csv from 'file://input.any'"
                + "  columns ['A', 'B', 'C'];\n"
                + "write $input to 'file://output.json';");

    final SopremoPlan expectedPlan = new SopremoPlan();
    final Source input =
        new Source(new CsvFormat().withKeyNames("A", "B", "C"), "file://input.any");
    final Sink output = new Sink("file://output.json").withInputs(input);
    expectedPlan.setSinks(output);

    assertPlanEquals(expectedPlan, actualPlan);
  }