2014년 11월 30일 일요일

Import CSV file into list


i can't import csv files directly to a list ????
plz help.....
i'm tired of looking around...and all examples are of tinyDB and webviewr....
i want to store from csv to list

--
Yes, you can import csv data directly to Lists. There is frequently no need to import them into a TinyDB and then use them in a list.
If you can do it with a TinyDb, you can adapt the code to using a List.

Be careful "i want to store from csv to list"    You can only temporarily 'store' to a List.  When the app closes, all data in the List disappears; so if you have to store your results, you will most likely need a TinyDB.   Data in a list is ephemeral, in a TinyDB it is persistent.

What have you tried?    Post a screen capture of your blocks and you will get advice.

--
use the list from csv table block, see also the documentation http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#listfromcsvtable

list from csv table


Parses a text as a CSV (comma-separated value) formatted table to produce a list of rows, each of which is a list of fields.
Rows can be separated by newlines (\n) or CRLF (\r\n).

--
thank you for your attention.....
well, i tried a lot !!
this is my last approach......
this is do NOTHING !!!
(p.s.: the file uuu.csv already in th assets)

--
this is my last approach....and it did nothing but showing a text in the spinner or on the label......so plz help!!
thank you for you attention

--
and i'm going to READ from csv file.....i'm not gonna store anything!!!
sorry for not expressing the case very well!!!

--
if you want to read from a file, you should use the FIle component together with the File.ReadFrom block, see also the documentation http://ai2.appinventor.mit.edu/reference/components/storage.html#File

then in the File.GotEvent block use the mentioned list from csv tableblock to convert the text into a list

--
i've done that before....and get stuck as shown.............

--
The file name needs a path. e.g. /mnt/sdcard/uuu.csv or file:///android_asset/uuu.csv

--
yeeeeey!!!
it worked....finally....
thank you all for your helpful notes...

--
and now ...csv file encoding issue...
arabic chars. shows as ?????????
i've saved the file with different encoding...non worked!!!

--
What does your arabic character csv look like?     Arabic is a right to left scripting language      ,اسمي ستيف ,أنا أعيش في ولاية تكساس , أحب AI2 هذا هو مثال باستخدام. AI2 لبناء التطبيق متعدد اللغات. أرجو أن أكون حصلت على الترميز صحيحة        is what an Arabic csv should look like.  You should also use the Screen Property    AlignHorizontal and set it to Right   ; unfortunately AI2 does not have a block to make that setting so you may have to put your Arabic on a separate screen if you are switching between languages.  Pardon my Arabic, I know very little and what is in the Arabic csv is the result of Google Translate.

Edit:  These screens are created by using csv files:


--
When you save your Arabic script in perhaps Notepad or where ever, did you set encoding to UTF-8 and save as UTF-8?

--


댓글 없음:

댓글 쓰기