use of org.polymap.core.data.refine.impl.CSVFormatAndOptions in project polymap4-core by Polymap4.
the class ImportCSVTest method testSSV.
@Test
public void testSSV() throws Exception {
// ; separated file
File wohngebiete = new File(this.getClass().getResource("/data/wohngebiete_sachsen.csv").getFile());
File tmp = File.createTempFile("foo", ".csv");
com.google.common.io.Files.copy(wohngebiete, tmp);
ImportResponse<CSVFormatAndOptions> response = service.importFile(tmp, CSVFormatAndOptions.createDefault(), null);
assertEquals(";", response.options().separator());
// get the loaded models
ColumnModel columns = response.job().project.columnModel;
assertEquals(12, columns.columns.size());
List<Row> rows = response.job().project.rows;
assertEquals("Baugenehmigungen: Neue Wohn-u.Nichtwohngeb. einschl. Wohnh.,", rows.get(0).cells.get(0).value);
assertEquals(471, rows.size());
assertEquals("neue Wohngeb. mit 1 od.2 Wohnungen, Räume u.Fläche d.Wohn.,", rows.get(1).cells.get(0).value);
CSVFormatAndOptions options = response.options();
options.setSeparator("\\t");
service.updateOptions(response.job(), options, null);
columns = response.job().project.columnModel;
assertEquals(1, columns.columns.size());
rows = response.job().project.rows;
assertEquals("Baugenehmigungen: Neue Wohn-u.Nichtwohngeb. einschl. Wohnh.,;;;;;;;;;;;", rows.get(0).cells.get(0).value);
assertEquals(471, rows.size());
Project project = service.createProject(response.job(), options, null);
rows = project.rows;
assertEquals("Baugenehmigungen: Neue Wohn-u.Nichtwohngeb. einschl. Wohnh.,;;;;;;;;;;;", rows.get(0).cells.get(0).value);
assertEquals(471, rows.size());
}
use of org.polymap.core.data.refine.impl.CSVFormatAndOptions in project polymap4-core by Polymap4.
the class ImportCSVTest method testEncodingTSV.
@Test
public void testEncodingTSV() throws Exception {
// ; separated file
File wohngebiete = new File(this.getClass().getResource("/data/example-utf8.tsv").getFile());
ImportResponse<CSVFormatAndOptions> response = service.importFile(wohngebiete, CSVFormatAndOptions.createDefault(), null);
assertEquals("\\t", response.options().separator());
assertEquals("UTF-8", response.options().encoding());
// get the loaded models
ColumnModel columns = response.job().project.columnModel;
assertEquals(12, columns.columns.size());
List<Row> rows = response.job().project.rows;
assertEquals(2, rows.size());
// assertEquals( "Jay Roach", rows.get( 1 ).cells.get( 4 ).value );
Serializable valueBefore = rows.get(1).cells.get(3).value;
response.options().setEncoding("ISO-8859-1");
// Map<String,String> params = Maps.newHashMap();
// params.put( "importingJobID", "" + response.job().id );
// params.put( "start", "0" );
// params.put( "limit", "5" );
// rowsResponse = service.post( GetRowsCommand.class, params );
// JSONObject rowsResponseBefore = new JSONObject( rowsResponse.toString() );
service.updateOptions(response.job(), response.options(), null);
rows = response.job().project.rows;
assertEquals(2, rows.size());
Serializable valueAfter = rows.get(1).cells.get(3).value;
assertEquals(valueBefore, valueAfter);
// // Serializable valueBefore = rows.get( 1 ).cells.get( 4 ).value;
//
// rowsResponse = service.post( GetRowsCommand.class, params );
// JSONObject rowsResponseAfter = new JSONObject( rowsResponse.toString() );
}
use of org.polymap.core.data.refine.impl.CSVFormatAndOptions in project polymap4-core by Polymap4.
the class OperationsTest method testSSV.
@Test
public void testSSV() throws Exception {
// ; separated file
File wohngebiete = new File(this.getClass().getResource("/data/wohngebiete_sachsen.csv").getFile());
File tmp = File.createTempFile("foo", ".csv");
Files.copy(wohngebiete, tmp);
ImportResponse<CSVFormatAndOptions> response = service.importFile(tmp, CSVFormatAndOptions.createDefault(), null);
assertEquals(";", response.options().separator());
assertEquals("ISO-8859-1", response.options().encoding());
// get the loaded models
ColumnModel columns = response.job().project.columnModel;
assertEquals(12, columns.columns.size());
List<Row> rows = response.job().project.rows;
assertEquals("Baugenehmigungen: Neue Wohn-u.Nichtwohngeb. einschl. Wohnh.,", rows.get(0).cells.get(0).value);
assertEquals(471, rows.size());
assertEquals("neue Wohngeb. mit 1 od.2 Wohnungen, Räume u.Fläche d.Wohn.,", rows.get(1).cells.get(0).value);
CSVFormatAndOptions options = response.options();
options.setSeparator("\\t");
service.updateOptions(response.job(), options, null);
// Map<String, String> params = Maps.newHashMap();
// String columnToRemove = columns.columns.get( 2 ).getName();
// params.put( "columnName", columnToRemove );
// params.put( "project", "" + response.job().project.id );
// service.post( ReorderRowsCommand.class, params );
//
// columns = response.job().project.columnModel;
// assertEquals( 11, columns.columns.size() );
}
use of org.polymap.core.data.refine.impl.CSVFormatAndOptions in project polymap4-core by Polymap4.
the class ImportCSVTest method testMoviesTSV.
@Test
public void testMoviesTSV() throws Exception {
// ; separated file
File wohngebiete = new File(this.getClass().getResource("/data/movies-condensed.tsv").getFile());
ImportResponse<CSVFormatAndOptions> response = service.importStream(new FileInputStream(wohngebiete), "wohngebiete_sachsen.csv", "text/csv", CSVFormatAndOptions.createDefault(), null);
assertEquals("\\t", response.options().separator());
// get the loaded models
ColumnModel columns = response.job().project.columnModel;
assertEquals(8, columns.columns.size());
List<Row> rows = response.job().project.rows;
assertEquals(20, rows.size());
assertEquals("Jay Roach", rows.get(3).cells.get(1).value);
}
Aggregations