Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

reading csv file  RSS feed

 
imran quazi
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I want to read a csv file and separate out and store in String each comma separated values. I am stuck at reading a single line at a time. Can anybody please show me a piece of code to do these?

Thanks
 
Ricky Martaputra
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use FileReader, BufferedReader and StringTokenizer

 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't forget to allow for values that have commas embedded in them and for blank values, and probably other quirks of csv that I haven't thought of.
There are a number of java csv parsers available that handle all these things. Try googling 'java csv parser' - it's better than reinventing the wheel.
 
Milan Jagatiya
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
try below link..CSV Parser will helps you....
http://ostermiller.org/utils/CSV.html

enjoy......
milan.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!