csvparser

Naive csvparser. This code may work, or it may not. I just got bored by writing it repeatedly, so I thought I'd publish it.

Sample usage:

String data="\"hello\",\"world\"\n\"wie\ngeht's\",\"dir\"";

CsvParser cp = new CsvParser(data, seperator:",", quotemark:"\""); while(cp.moveNext()) {

while(cp.current.moveNext()) 
  print(cp.current.current);

}

Improvements:

  • introduction of setHeaders(List<String>) method for the parser
  • introduction of toList() and toMap(List<String>) methods for the individual lines
  • introduction of getLineAsList() and getLineAsMap({List<String> headers}) methods for the parser
  • introduction of setHeaders:false option to CsvParser. This will attempt to set the headers to the first line in the file
  • added CsvFieldType enum class

Libraries

csvparser