Pesquisar neste blogue

segunda-feira, 17 de dezembro de 2018

CSV handling in Java

These past days i've been trying to load CSV files in Java. Used opencsv with some degree with success, however some fields were still misinterpreted .
Next an old friend by name of FasterXML/jackson came to the rescue, however i was still having some issues.
Last but not least on stackoverflow.com (where else) i came across https://simpleflatmapper.org/ and with something like:


CsvParser.separator(';')

   .mapTo(MyClass.class)

   .headers("my","headers","list")

   .iterator(new File(filepath));


I was up and running .

Note : If you find MalformedInputException check if your input is UTF-8 , more info here  http://biercoff.com/malformedinputexception-input-length-1-exception-solution-for-scala-and-java/

Sem comentários:

Enviar um comentário