use of com.khartec.waltz.model.catalog.ParseAnalysis in project waltz by khartec.
the class TabularFileAnalyserTest method foo.
@Test
public void foo() throws IOException {
char[] delimeters = new char[] { ',', '|', '\t', ';', '!' };
char[] quoteChars = new char[] { '"', '\'' };
List<ParseAnalysis> analysisResults = ListUtilities.newArrayList();
for (char quoteChar : quoteChars) {
for (char delimeter : delimeters) {
InputStreamReader simpleReader = getReader();
CsvPreference prefs = new CsvPreference.Builder(quoteChar, delimeter, "\n").ignoreEmptyLines(false).build();
CsvListReader csvReader = new CsvListReader(simpleReader, prefs);
List<String> cells = csvReader.read();
ImmutableParseAnalysis.Builder parseAnalysisBuilder = ImmutableParseAnalysis.builder().quoteChar(quoteChar).delimiterChar(delimeter);
while (cells != null) {
parseAnalysisBuilder.addFieldCounts(cells.size());
cells = csvReader.read();
}
ParseAnalysis parseAnalysis = parseAnalysisBuilder.build();
analysisResults.add(parseAnalysis);
}
}
analysisResults.forEach(r -> {
System.out.println(r.quoteChar() + " " + r.delimiterChar() + " => [ " + r.fieldCounts().size() + " ] " + r.fieldCounts());
});
}
Aggregations