I am developing an android application..i want to import data from csv file into a list in appinventor..1 method is to upload that csv file online and then extract data from it..is there a way by which i can keep that csv file in sd card and get data from it? If I upload that csv file and then extract data from it, then what is the shortest and simplest way??Any examples??
Normally this is not possible with App Inventor, but there is a trick to read a text file from SD card: you can use App Inventor together with embedded HTML/JavaScript, see an example here: http://puravidaapps.com/read.php
Meanwhile I prepared another example which imports a multiline csv file stored as asset in App Inventor on first run of the app and stores it as list of lists in TinyDB. Please find it here: http://puravidaapps.com/importCSV.php
Yes, you can store a csv file in sdcard and write a small parser to parse csv file to construct your list. If the file is available somewhere remotely, I recommend to download the file first and then parse the file.
Answer from here -> Get and Parse CSV file in android
//--- Suppose you have input stream `is` of your csv file then:
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
try {
String line;
while ((line = reader.readLine()) != null) {
String[] RowData = line.split(",");
date = RowData[0];
value = RowData[1];
// do something with "data" and "value"
}
}
catch (IOException ex) {
// handle exception
}
finally {
try {
is.close();
}
catch (IOException e) {
// handle exception
}
}
and may be have a look at this too,
来源:https://stackoverflow.com/questions/12167358/appinventor-import-data-from-csv-file-into-a-list