CSV parsing .. once again
Posted by Mike Haller
on Sunday, December 31. 2006
at 17:11
in Java
Who hasn't dealt with comma separated values? These damn little .csv files. Okay, there are a few Java libraries to handle CSV files, such as the Ostermiller lib. However, it's not usable in some environments (e.g. licensing conflict)."1000";1;;"0";"1000";;9;2000;"1000";"Sonstiges";"StÂck";;1,00;1754" "1001";1;;"0";"1000";;9;2000;"1000";"Sonstiges";"StÂck";;1,00;584" "1002";1;;"0";"1001";;9;2000;"1000";"Sonstiges";"StÂck";;1,00;255"
Then, in a new Java project, one is undecided whether to write a small importer which just fits the one .csv file you need to import. Then, there will always be another one and yet another one. Oh, and then there are the charset problems. Does the file originate from a legacy DOS application, a legacy Windows application? Or is it totally weird, because csv is only a de-facto standard and you cannot find a real specification anywhere? How do you handle the empty values with no quotes?
At that time, it'd be good to have a Java CSV library within reach.
Apache has the commons-csv library, and hopefully it gets out of the sandbox soon and will be merged with an existing library such as commons-lang or commons-io.
