Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Suhu Shah
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic