Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading CSV file in resources folder android

I am developing an android app in netbeans. I am trying to read CSV file using opencsv. When I put the file in resources folder and try to read it from there, there's an error while building saying invalid resource directory. Where should I store csv file so that it can be read each time the app starts?

like image 553
Sarit Adhikari Avatar asked Nov 14 '13 10:11

Sarit Adhikari


People also ask

How do I import a CSV file into SQLite database in Android Studio?

You can import a CSV file into SQLite table by using sqlite3 tool and . import command. This command accepts a file name, and a table name. Here, file name is the file from where the data is fetched and the table name is the table where the data will be imported into.

How do I view a CSV file?

Opening a CSV file is simpler than you may think. In almost any text editor or spreadsheet program, just choose File > Open and select the CSV file. For most people, it is best to use a spreadsheet program. Spreadsheet programs display the data in a way that is easier to read and work with than a text editor.

How does kotlin read data from CSV file?

Reading a CSV File in Kotlinget("/resources/students. csv")); Then, once we've read the file into the buffer, we can use the buffer itself to initialize a CSVParser instance: val csvParser = CSVParser(bufferedReader, CSVFormat.


1 Answers

you should put csv file in assets folder ..

InputStreamReader is = new InputStreamReader(getAssets()
                        .open("filename.csv"));

BufferedReader reader = new BufferedReader(is);
reader.readLine();
String line;
while ((line = reader.readLine()) != null) {
                        
}
like image 58
navneet sharma Avatar answered Oct 06 '22 19:10

navneet sharma