-2

I have this CSV file format:

"1", "testing <[image|media]>" , "1"

how can to read it from sdcard and put the parsed data in a listview or textview in Android?

agony
  • 563
  • 1
  • 9
  • 18
  • 2
    You should use [OpenCSV](http://opencsv.sourceforge.net/) for parsing the CSV data. – Kai Dec 20 '11 at 10:38
  • Adopt CSV Reader to your code,it will be a much simpler solution code rather than the other one. – Karthik Dec 20 '11 at 12:52

2 Answers2

2

You can use java.io.Reader and split string on ","

Konstantin Pribluda
  • 12,329
  • 1
  • 30
  • 35
  • Please be more elaborate. Clearly, the OP has no clue about those if he's asking this question....Also, A simple split might not work. What if the data has a double quote in it? – st0le Dec 20 '11 at 10:44
  • if the data has double quote or anything that can't be handled by a String.split, he definitely should use an external library – njzk2 Dec 20 '11 at 10:59
1

Take a look here where I describe a regex you could use. You may need to tinker with it to deal with the extra spaces you have on either side of your commas.

Please remember that rolling your own CSV reader is likely to cause you trouble down the line. Please try very hard to use a ready-made one like OpenCSV mentioned elsewhere.

Community
  • 1
  • 1
OldCurmudgeon
  • 64,482
  • 16
  • 119
  • 213