Modify existing CSV file

I understand that in this thread there is an existing CSV to edit but how about to add more info. then it will be save in the existing csv file. There is no definite guide for the existing similar topic.
Thanks

To add a new row to an existing (or new) csv file, use the Append block in the File component. For a csv you will want to add an \n to create a new line.

To edit entries in a csv file, you will need to read the file into an AI2 list, edit the contents, then save the list back out to the file as a csv table

Do you have simple code to add in listview and permanently modify in csv file.
using the list_revised.aia I tried to modify the data in the list view but it did not reflect on the CSV File.

The listview displays the data from a list
Modify the contents of the list (as I indicated above).

I will prepare an example....

BLOCKS

SCREEN

  • This simple example allows the user to enter a name and age to textboxes.
  • These two items are then appended to a csv table in a file called data.csv
  • The user can then read the file, and store the data as an AI2 list, which is shown in the listview
  • When a listview item is selected, the items are displayed in the edit textboxes, for the user to edit
  • On saving the edits the list is updated with the new values, then the whole list is saved to the file data.csv (overwriting the previous file contents
  • Reading in the file again will show the new file contents
1 Like

I create another Project and Follow this block created my own data.csv upload it as media.
I can input and modify data but when I try to input data then click the button3 there's this prompt:
*Cannot parse text argument to "list from csv table" as a CSV-formatted table.
*I tried to DL the data.csv in AIcompanion after entering some data well it is empty. I thought I had saved some.
is there a problem in my data.csv?

  1. In button3 event it should be list to csv table not from
  2. In my example the data.csv file is created in your ASD

Sorry I did not see the code clearly.... there is no Error anymore. But Where in my storage Can I see the created data.csv
the reason for this is if I need the gathered data to send to other device or the web.

As I said, the file data.csv is created in your ASD:

/storage/emulated/0/Android/data/<packageName>/files/data.csv

when you use the companion app this will be:

/storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/data.csv

How do you intend to send this file to other device or the web ? (it may be easier to do this in the app...)

I see it is in my storage after all I think because of my android version that I cannot find the data.csv I will move to uploading file to google Drive..

1 Like

You can look on the Play Store for a File Manager that will give you access to all the files in your app's ASD folders. I use Explorer to good effect on my Android 12 device

Sir TIMAI2 regarding the GOOGLE APP SCRIPT WEB APP URL Am I on the right track METRIC RAT AI2 - HOWTO: Create a Google Apps Script Web App bound to a Spreadsheet
I tried the Upload any file to Google drive but I need to add the script. I also see the old .csv that I created.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.