Programmer's Cookbook

Recipes for the practical programmer

Friday, June 13, 2008

 

Parsing Comma Seperated Values (CSV) in Java

I suggest using Java CSV Library, it is very easy to use. If you use Maven 2, you can use this to load it as a dependancy.


<dependency>
<groupId>net.sourceforge.javacsv</groupId>
<artifactId>javacsv</artifactId>
<version>2.0</version>
</dependency>


The code below reads in a CSV file, parsing one line at a time, splitting each line into the vals array.


CsvReader rdr = new CsvReader("simeFile.csv");
while (rdr.readRecord()) {
String[] vals = rdr.getValues();
...
System.out.println(vals.length);
// process here
}

Comments:
This is exactly the kind of useful content readers can benefit from. Thanks for sharing.ba analyst course online
 
Very informative content. I liked the simple explanation.dell boomi training

 
Follow a practical Workday Studio Tutorial to understand the fundamentals of integration development, configuration, data handling, and system connectivity. It can be a useful starting point for learners who want to build a solid foundation in Workday Studio.
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?