aspose file tools*
The moose likes Groovy and the fly likes Can OpenCSV parse CSV files and return data in a list as attribute:value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Can OpenCSV parse CSV files and return data in a list as attribute:value" Watch "Can OpenCSV parse CSV files and return data in a list as attribute:value" New topic
Author

Can OpenCSV parse CSV files and return data in a list as attribute:value

Suhu Shah
Greenhorn

Joined: May 24, 2010
Posts: 2
Hi folks,

I m new to this site and need some guidance in moving forward. We need a dynamic parser that will be working with a series of CVS files.. each having different fields and values.. however the format would be something like below..

"NAME","ADDRESS","CITY","STATE","POSTAL_CODE","CNTRY_CODE"
"NY-Correctional Facility","Exchange St","ATTICA","NY","14011","US
"
"Consolidated School Corp","205,East Street","Attica","IN","47918","US
"

Looking at OpenCSV it seems it can handle most of the data issues we have seen in CSV files, like comma inside values, carriage returns etc. However one of our requirements is that after parsing the CSV files I need the tool to return it as a list with the format attribute:value where attribute would be the corresponding field from the header line.
ie something like this..

NAME:NY-Correctional Facility, ADDRESS:Exchange St, CITY:ATTICA, STATE:NY, POSTAL_CODE:14011,CNTRY_CODE:US

Is there any way I can get OpenCSV to do this?

I m kinda new to all this, so if the solution is simple, do excuse me

Thanks in advance
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm sure it can't do that (but could be wrong). It'd be really easy for *you* to do that, though--why not give it a shot?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can OpenCSV parse CSV files and return data in a list as attribute:value