Replace one item of .csv file

Hello,

Is it possible to add some block in my project in order to replace any single item .csv file if I want to updating that .csv file from time to time.
Thank you

You won’t be able to update the links.csv file because it is in your assets.

You will need to copy this file to your sdcard or the app private directory and open it from there.

If you pull the entire csv file into your app as a list, you can make changes to this using blocks, then save the entire list (as csv) back to the file, overwriting the existing data. This is the easiest way.

Hi Prity_N,

Yes as TimAI2 mentioned there is no direct update on CSV files. I had also the same issue. That is why I decided to use MySQL database. For replacing the CVS file there is one tutorial on youtube that helps.

Hello TimAI2,
That is fine.
How can I add blocks to replace any single item which is in sdcard. Do I need to add any extension for editing or deleting. Please give me an example if you have.

blocks (1)

How to work with Lists by Sajal Dutta

@Prity_N

Tim has provided a good solution.

Alternative, you may use the PathToAssets method from @Taifun's Tools Extension with File Extension.
PathToAssets

@sarkar

Files in the assets are read only, you cannot write to them.

Using // to access files in assets, / for files in sdcard, works in both companion and compiled apps

Oh yes! Thanks!

In fact, I am facing a problem when downloading the files from google drive and when stop downloading all files some of csv files are downloaded but can’t be open because they are not downloaded properly or because not complete download.
I attach the .aia and see how it looks like
I just put 4 files as example because I have a lot of csv files.

sorry to say, but the PathToAssets method is designed to be used only for the webviewer component...
see also the documentation App Inventor Extensions: Tools | Pura Vida Apps

Note: this method will work only for the webviewer component. It does not make sense to use it for other components!

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

AIA tested, nothing wrong there, all files downloaded correctly.
You might want to check the UTF-8 encoding of the files.

image

image

Hi TimAI2,

You are correct. There is nothing wrong in this .aia because it has just 4 .csv files.
But the one I have has 1000 file of .csv :slight_smile:

But they are all in google drive, so you just have a list of 1000 in your links.csv file.And you download one by one ? - you could break up the list to a more manageable list of lists ?

If you need to download 1000 all in one go using the file by file method, I suggest you do it in batches of 50 - 100, depending on their size, or just download a file as needed ?

depending on the size, you also could create a zip file and download only that zip file, then unzip it using the zip extension

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Hello Taifun,

Your suggestion is the best idea to create a zip file and download only that zip file then unzip it using the zip extension. But I don’t know how to do it because I don’t have an example with more details. And .aia in the link https://puravidaapps.com/zip.php has different example. I will try to create a small example. Thank you Taifun and TimAI2

The zip file and unzip the file is pretty easy but I am confusing how to recreate the path in order to download the zip file into it then unzip that file in the same path /download/box :slight_smile:

Try this
(for example: I put csv.zip (1.csv, 2.csv, 3.csv) into the assets, you have to download it first from https://docs.google.com/uc?... to: /storage/emulated/0/Download/Box/csv.zip):

Hi Anke,
I have done the blocks but I think I am still confuse. I need to download every single .csv file when the user select any item from ListPicker individually and not all files at one time
.
Please have a look to my project.

Thank you so much for helping me.

You didn't upload csv.zip file to the assets.
So the folder: /storage/emulated/0/Download/Box/csv/ is not created

Try this one: Download_zip2.aia (244.5 KB)

grafik

… download my aia, build APK, install it, open the app (nothing else) and check if inside this folder
/storage/emulated/0/Download/Box/csv/
these 3 files exist: