Append and read csv file

What I want to do is :
day 1, user enters some values in textboxes > these values are stored in the 1st row of a csv file
day 2, user enters new values (corresponding to the same fields) > theses values are stored in the 2nd row of the csv file
User can reload these datas back, e.g. asking "show datas of day 5"

Here I made a simplified version just to practice and try to understand the mechanism of what I want to do.
I solved part of the idea, but there are many points not working ; I know it comes from that I don't fully understand functionning of lists... But I have trouble transfering in my project what I learned making tutos (or what I read consulting other posts here). And maybe my approach with a csv file is wrong.

-> why are those brackets here ?
-> how can I append the datas of the new day on a new line ?
-> when entering new datas, why aren't the old one erased in the variable (after having been copied in csv file) ?

I type 3 datas, and then "valider" (enter)

Button "récupérer" (get datas) is supposed to make the csv file read and show (a) the first row and (b) the first element of first row ... lol ... I must have mistaken somewhere !!

Here, I added a second and a third list of 3 names

I am sure that it's simple enough so you will look at it and find what I did wrong :innocent:
I wait with impatience your feedback about my unsuccessfull attempts :wink:
Thanks in advance :pray:

Try like this:

The button 1 block adds a string to a row in the text file and a line return - \n. This is the correct format for a csv file (table).

Button 2 reads the file, then the contents are converted to an AI2 list of lists from the csv table, and for this purpose shown in a label. You can format and control this list however you want.

Thank you ! Now I succeeded doing things exactly as I wanted (and the blocks are more simple) :smiley:
So my datas shouldn't be treated as lists but as text to be saved in the csv file ?
have a nice day !

I am very proud to anounce that on Monday I will be able to give my first (almost) finished app to my first end user ... I can't wait !! :partying_face:

But (there's always a but) : this app refers to an external csv-file ; it worked perfectly when I was on companion, but my built app can't find the csv-file to read.
I have read and re-read (etc) the little text about slashes, I have pasted my file (obviously not) everywhere on my tablet but I can't find where to paste this file so my app can find it :sob:

Where should I paste my file if it's refered to /file.csv, //file.csv and file.csv ?

Thank you

Why not upload it as an asset in your project?

you mean internally stored ?
because it's a list of words my user will work with, and I want to load a new list when he's finished, or an custom list for another user.

does it seem right to you doing so ?

PS : not sure to fully understand what "asset" means or actually is ...

Yes inside the app. An asset is a mediafile like image, sound, txt. Maybe show how you load your file now.

I gues you are talking about this topic

To keep everything in one place i merged the two topics.

ok, thks

My idea is : I write the words-list on a computer (much more rapid) and I paste it in the right folder on my user's phone.
Then the app is reading it to retrieve every word in a list :

1 Like

You should read this topic from @Anke

1 Like

Oh thanks :+1:

So if I understand well, this part is for me, but I should put a slash in my Read.File component ?
How do I give permission to Read_/write_external_storage ?
Where do I find these storage folder ? :upside_down_face: (sorry)

2. External Storage
The root directory of the External Storage is:

/storage/emulated/0/  or
file:///mnt/sdcard/ or

To access the external storage, READ_/WRITE_EXTERNAL_STORAGE permission is required.

The Private directory is


This Private directory can be used with the File component to save / read text (setting the path without a slash).

If you want to save in / read from the external storage you must start with a slash:
/test.txt (the File component uses a relative path)

This text file is then read from the root dir of the external storage (absolute path):


These permissions are requested automatically.

okay ...
I am not sure to have explained clearly : my csv-file isn't saved by the app, I want to paste it myself on the phone.

  • I don't find the storage folder on my tablet (I found it on my phone)

Right folder?
On my user's phone? How?

Android version?

Tablet : 5.1.1
my Phone : 9
the end user's phone : don't know, haven't installed yet, I see him on Monday

I am sorry if I don't master either the vocabulary to explain what I am trying to do either the logic of programmation - I try to obtain a certain result with the "tools" I master +/- and try to learn new ones on this way :slight_smile:

The app's goal is to show everyday a new word do end user (aphasic patient) and he has to do some "exercises" with that word. The presented words are taken from a list he gave me. This list consists of 280 words. Therefore, it's easier for me to type it on the computer in a csv-file and then send it on my device than entering it word by word via the app on the phone/tablet.
Furthermore, maybe later I will use the same principle with another patient, but not with the same words.
The solution I'm thinking about is having the word list stored externally from app, so I can change the list (or my patient can) whenever I want. It's probably not the smartest solution from a programmer point of view, if you have a better one I'll be glad to learn.

When I was building the app and working with companion, I sent the csv-file on my phone (via mail or dropbox) and copied-pasted it in the data subfolder of the App Inventor folder. I could easily load the wordlist using the dedicated button and component ... and now, I am wondering how to do this with the packaged app.

I hope my explanation are clearer ... and you can help me be a better programmer :slight_smile:

That is not possible because the directory


is only created / used for degugging and is not available for the compiled app (APK). Files that are saved here (with the File component by saving a text file without a slash) are saved with the APK in the internal storage:


This directory is only accessible with a rooted device.
You should therefore save the csv file in a folder of the external storage, for example:

/storage/emulated/0/Documents/ or /storage/emulated/0/Download/

If you enter new, more words, the length of the list should actually increase, right?
And how does the user know which word from the list to work with afterwards? How does the user know which word was added?

Questions & questions ... so to shorten this, create a small test aia with only 3-5 words and post the blocks (aia). Put the csv file in the assets (Media).

ok ... some tries later :
with /liste.csv in Read.File component and the file pasted on sdcard/ it worked :smiley:
how should I write the address if I want to decide the folder where file must be paste (and not simply the root of sdcard) ? /folder/subfolder/liste.csv ??

you can see here my app and liste.csv separately
mot_du_jour.aia (107.2 KB) liste.csv (3.2 KB)

I hope you better understand my goal by seeing the result :slight_smile:

About the wordlist : the app presents everyday a different word (one word per day) ; user can't choose.
The stock of words comes from 3 possible sources :

  • 2 words are pre-stored as a startpoint
  • user can upload the csv-list (this list can be 10 or 1000 words if he wants) -> integrated in tinyDB (csv-file not modified)
  • user can enter new words manually one by one -> integrated in tinyDB (csv-file not modified)

Apart from doing some exercises with the word of the day, user can :

  • see list of previous words treated (and the responses he gave - my project for later is that he can modify his responses ; for now he can do it only the day he entered them)
  • see list of words stored in tinyDB, erase a word, erase the whole list, add a word or upload a csv-list
    Instructions (or help section) for the user to know what he has to do and how to do it remain basic, at this point. I will show him tomorrow when I see him.

Thank you for having a look, I'll be glad to have your comments on how to improve this app's structure :slight_smile: (from my point of view, the Screen.Initialize component is quite frightening :scream:)

/storage/emulated/0/Documents/ or /storage/emulated/0/Download/

For the File component you must use the relative path (as I already said):

/Documents/liste.csv or /Download/liste.csv

I think I forgot to thank you, it may seem obvious to you but that was the information needed :slight_smile:
App is now on my end user's phone (I asked him to report bugs ... I hope there are not too much !!)