"'crazy''data\"here'||-345||-3.45E-4||61 62 63 64 65 66 67||true||" + NL +
"C:\\temp\\some_file.txt||25||0.0||||false||" + NL;
assertEquals(expected, out.toString());
+
+ ExportFilter oddFilter = new SimpleExportFilter() {
+ private int _num;
+ @Override
+ public Object[] filterRow(Object[] row) {
+ if((_num++ % 2) == 1) {
+ return null;
+ }
+ return row;
+ }
+ };
+
+ out = new StringWriter();
+
+ ExportUtil.exportWriter(db, "test", new BufferedWriter(out), false,
+ ExportUtil.DEFAULT_DELIMITER,
+ ExportUtil.DEFAULT_QUOTE_CHAR, oddFilter);
+
+ expected =
+ "some text||some more,13,13.25,\"61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78" + NL +
+ "79 7A 61 62 63 64\",true," + testDate + NL +
+ "C:\\temp\\some_file.txt,25,0.0,,false," + NL;
+
+ assertEquals(expected, out.toString());
}
}
);
assertTable(expectedRows, t);
+
+ ImportFilter oddFilter = new SimpleImportFilter() {
+ private int _num;
+ @Override
+ public Object[] filterRow(Object[] row) {
+ if((_num++ % 2) == 1) {
+ return null;
+ }
+ return row;
+ }
+ };
+
+ tableName = db.importFile(
+ "test2", new File("test/data/sample-input.tab"), "\\t", oddFilter);
+ t = db.getTable(tableName);
+
+ colNames = new ArrayList<String>();
+ for(Column c : t.getColumns()) {
+ colNames.add(c.getName());
+ }
+ assertEquals(Arrays.asList("Test1", "Test2", "Test3"), colNames);
+
+ expectedRows =
+ createExpectedTable(
+ createExpectedRow(
+ "Test1", "Foo",
+ "Test2", "Bar",
+ "Test3", "Ralph"),
+ createExpectedRow(
+ "Test1", "",
+ "Test2", "Partial line",
+ "Test3", null),
+ createExpectedRow(
+ "Test1", "buzz",
+ "Test2", "embedded\tseparator",
+ "Test3", "long")
+ );
+ assertTable(expectedRows, t);
+
db.close();
}
}