Iterate through csv files with just 1 File Component?

75 views
Skip to first unread message

Tim Carter

unread,
Oct 11, 2015, 8:07:41 AM10/11/15
to MIT App Inventor Forum
The new file component certainly helps a lot in loading and saving data in an app.

In setting up an app the other day, I needed to load up some lists from files, and seeking to be a good coder (newbie!) I set about creating a loop, using one file component, to load up the lists from files. This started to fall apart with the "File1.GotText" block, which cannot be hooked into the "For each Item in List" block. Consequently, my attempt only returned the last file.

Some sample blocks:


Am probably missing something, or can it not be done?


Thanks


Tim


Taifun

unread,
Oct 11, 2015, 9:18:39 AM10/11/15
to MIT App Inventor Forum
the file component works asynchronously
which means, after having received the text of the first file then start reading the second file etc.
see also the logic used here (which uses the web component, but the logic is the same)
Taifun

Tim Carter

unread,
Oct 11, 2015, 12:01:48 PM10/11/15
to MIT App Inventor Forum


Hi Taifun

Thanks for making me think it through :)

reworked my blocks using the filebyfile example (which I know well enough!) and it worked :) The order of things ;)

Revised sample blocks


Regards


Tim


Reply all
Reply to author
Forward
0 new messages