Many thanks Taifun and ABG!
As soon as possible I would like to do a couple of tests on my app beginning from your precious tips. I will come back soon!
Dear all, after a lot of tests I'm sure that the time delay is due to the 'compare text' section of my blocks.
(not due to csv import, or spinner population, etc...)
I attach 2 simplified project.
TEST_CSV
After you select 'scegli country', the button 'crea lista filtrata' only populate the variable... and here I have a 40s time delay
Whit other buttons you can after populate a label or the spinner, or select one element from the countries_cities list
TEST_CSV_con_TINYDB
Here I have modified TEST_CSV App by introducing TinyDB. My intentiin is to populate the DB at initialize, with a tag for one country and a list of cities as value for a tag.
... But here I have an INFINITE delay
How you suggest to solve my problem?
TEST_csv_con_TINYDB.aia (780.3 KB)
TEST_csv.aia (779.8 KB)
Use a sqlite extension, for example App Inventor Extensions: SQlite | Pura Vida Apps
There also exist other sqlite extensions
Prepare your data in a table inside the database and import the database on first run of your app, for an example follow the link above
Then use select statements to retrieve the data you need
Taifun
Thank you Taifun. I asked info regarding SQlite at the beginning of this discussion...
I will use my app for business.
Can I free use SQlite and SQlite extension for business?
Can I free use SQlite without time limits ?
What about a server for DB hosting that is free without time limits?
There are Free and Paid SQLite extensions
You can use them for whatever purpose you choose, within the requirements of any licence set on the extension.
Free or Paid, there are available for use without time limits
There are many "free" hosting servers available, you will need to find one that suits your needs. That is beyond the remit of this community.
Yes, the license is per app developer and you can create as many projects as you like with the extension
You can search the internet for free web hosts, but frequently they only offer a webpage but not accessing data in a MySQL database
EDIT: see for example Can anybody help me with this? Web Component not sending data to php - #3 by Juan_Antonio
Also your data is static and does not change, isn't it? So no online database would be required... also a local solution as the local sqlite database does not require internet access and could be faster than querying an online database because you can save the transfer time from the app to the database and back again
Taifun
Please Taifun, how can I create and use a local SQ lite? It seems the best solution
Here is a basic sqliteDB of your data
cc.txt (4.1 MB)
Rename cc.txt to cc.sqlite.
What you should really do it setup a relational database, so that the cities are represented by the index of the country, e.g. Vila,Andorra -> Vila,1
this will help to speed things up even more.
You can find information on my webpage App Inventor Extensions: SQlite | Pura Vida Apps
Also a sqlite tutorial might help
Taifun
Many many thanks!!
I will try to setup a local SQlite and I will came back soon to give you a feedback.
I hope to solve in this way...
Just to see if it would work, I tried a simple inline filter to get cities of a selected country:
Surprisingly, this got a stack overflow (8MB).
Even just the filter part got a stack overflow:
Apparently, there's little headroom for piping at runtime.
Maybe if I compile it?
Even compiled, I got a stack overflow.
(Note I had to use the file name helper blocks for the CSV files. The Companion was more forgiving on case mismatches between file names.)
So the elegant approach fails.
Next attempt would be a trudge through the input csv table, after conversion. to load a dictionary of country cities.
Interesting. Which of the AIAs were you using to test this? This should result in tail call recursion being applied to prevent a stack overflow, so I'd like to investigate further.
I didn't preserve the failed stack overflow version, but jumped into a dictionary based version, yet to test.
I'll whip that up for you.
TEST_csv_piped.aia (779.7 KB)
I stripped the blocks down to the bare essentials.
Load the two files into global tables, one after the other.
Load the Country name picker
After picking a country, load the city picker from the city-country table.
That's where it gets the 8mb java stack overflow error.
The dictionary based version loads and filters okay, but might be speeded up for later runs by caching to a TinyDB Namespace.
I'll try that next.
TEST_csv_dictionaries.aia (780.3 KB)
And here's the ultimate extension-free TinyDB retentive version, with loading on the first run only:
TEST_csv_TinyDB_Namespace.aia (780.6 KB)
P.S. You might want to switch to List Pickers instead of Spinners.
They have optional search boxes.
I am surprised by how many cities are in even the tiniest of countries, and at how soon I lose patience with scrolling long lists.
I forgot to ask, will this have to also run on iOS?
Dear all, very thank you for time spended to solve my problem....I appreciate!
TIMAI2 the speed of your last .aia app is impressive! I think I will use the SQ lite as in your example.
Is that a local SQlite?
Also this will help you😊
ABG thank you for your app "ultimate extension-free TinyDB retentive version".
I have tested it and in first run the time to wait is about 90s
I will probably use the solution of TIMAI2 with SQlite.
For what concern the IOS...I know that apps that use extensions can not be exported to be used in IOS...is it true?
My app uses a lot of extensions: have you a solution?