I'm doing a sample Quiz application in Android. I used array to store the Questions and Answers, now I wish to store the questions and answers in a .csv file.
it is possible to parse .csv file in Android?
-
CSV files are files containing comma separated values. You can read these like any other textfile. Apart from that your question is really broad and vague and can't be answered reasonably imho.user658042– user6580422011-12-05 12:40:59 +00:00Commented Dec 5, 2011 at 12:40
-
possible duplicate of Get and Parse CSV file in androidPeeHaa– PeeHaa2012-09-02 01:38:45 +00:00Commented Sep 2, 2012 at 1:38
4 Answers
Put you .csv in the assert folder and access it as follow
I was using .csv to get the list of counter in my application..
public ArrayList<String> COUNTRIES = new ArrayList<String>();
try {
is = res.getAssets().open("country.csv");
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line;
while ((line = reader.readLine()) != null)
COUNTRIES.add(line);
}
catch (IOException ex) {
// handle exception
}
finally {
try {
is.close();
}
catch (IOException e) {
// handle exception
}
}
Comments
I think this is general discussion, (Not specific to android)
The CSV ("Comma Separated Value") file format is often used to exchange data between disparate applications. The file format, as it is used in Microsoft Excel, has become a pseudo standard throughout the industry, even among non-Microsoft platforms.
There are many ways to generate a csv file. A csv file is a comma delimited data file. Many applications such as Excel or MS Access allow one to save data in csv format. But you can also generate csv files yourself as long as the data is comma delimited and each line is ended with a line break.
Comments
CSV, comma separated values, files are commonly used to transport large amounts of tabular data between either companies or applications that are not directly connected. The files are easily editable using common spreadsheet applications like Microsoft Excel.
Read more
And take a look at these Samples on reading / writing *.csv
.