AppInventor: Import data from csv file into a list

旧时模样 提交于 2019-12-04 15:14:30

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

VendettaDroid

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,

http://code.google.com/p/secrets-for-android/source/browse/trunk/src/au/com/bytecode/opencsv/CSVReader.java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!