Do a search in the table.csv and does not leave stores a value to found.

92 views
Skip to first unread message

Marcos_Paulo

unread,
Mar 10, 2019, 9:01:10 PM3/10/19
to MIT App Inventor Forum

Hello,

My application is to collect data in the field.
It has two text boxes, one Text_Code and another Text_KM, and the save button.
Every time I fill a machine I store a vehicle code and its mileage.
Inside the device has a table.csv with vehicle code and its latest mileage.
I would like to know how I do it: when entering the code and horimetro it does a search in the table.csv and finds the code typed and does not let to store the mileage if it is smaller than the value found in the table.


thankful

ABG

unread,
Mar 11, 2019, 12:08:51 PM3/11/19
to MIT App Inventor Forum
TinyDB is easier to update than a table.

Use the vehicle code as the tag and the mileage as the value.

On startup, check if the number of tags in TinyDB is zero.
If zero tag count (length of list) load the table.csv file,
convert it to a table (list of lists), and for each row in the table
store it in TinyDB, 1st item is the tag, 2nd item is the value.

I suggest adding a ListPicker for easy vehicleID lookup,
loaded from the tags list of TinyDB, to avoid having 
to always type the vehicle ID.

See the Books and Tutorials section of FAQ
and the TinyDB section of FAQ

ABG

TimAI2

unread,
Mar 11, 2019, 6:23:29 PM3/11/19
to MIT App Inventor Forum
This example may be what you want or give you some ideas
I started with a "master list of equipment and latest mileages
If you have many devices in the field accessing the same equipment
this may require some work "back at base"

The example updates the master list with each successful entry
and also generates a log of all records, last first.

Everything assumes that the latest record has the highest mileage !

BLOCKS

blocksfielddata.png


aia attached


dataInField.aia

Marcos_Paulo

unread,
Mar 11, 2019, 11:05:19 PM3/11/19
to MIT App Inventor Forum

Hello

Thank you for your help.
Here is my list of equiments attached.
How do I search from this list, because I update it daily.
And it would not be to use the ListPicker because there are too many equipment, typing would quit faster.
Then I would put a TextBox!
Would you help me program?

Thankful.
Teste_CSV.csv

TimAI2

unread,
Mar 12, 2019, 3:53:52 AM3/12/19
to MIT App Inventor Forum
You could just use the filterbar for the listpicker (but this destroys the indexing)


or use a nested listpicker, to select by prefix, e.g. CB, TP etc.

Also to help with typing:

ABG

unread,
Mar 12, 2019, 11:41:38 AM3/12/19
to MIT App Inventor Forum
Your CSV file is not CSV.

It uses semicolons (;) instead of commas (,).

Also, those are very low mileages.
What are you renting, turtles?

ABG

Capture.PNG

Marcos_Paulo

unread,
Mar 12, 2019, 9:19:45 PM3/12/19
to MIT App Inventor Forum

Hello Abraham,

Yes, I tested it in MIT App Inventor, I made a button to show the table in a ListView.
Our colleague posted a project.aia which is very similar with what I need, however he put a variable with 4 equipments.
I have a list with 200 equipment, I would not have to type this all, plus I have to update the table daily.
Help me with blocks to do what you suggested, like putting the table inside TinyDB.

Thankful.
Teste_CSV.csv

ABG

unread,
Mar 13, 2019, 5:53:42 PM3/13/19
to MIT App Inventor Forum
I have to update the table daily.

This sounds like a fly in the ointment.

Will other people be updating mileage independently of
the person operating this device?

That would call for a shared data base like Firebase or CloudDB.

Or did you mean by this that you have to use the app on the device daily?

ABG
 

ABG

unread,
Mar 13, 2019, 9:33:45 PM3/13/19
to MIT App Inventor Forum
See attached for how to do this with two step List Pickers for speed.

The Options button exposes dangerous one time startup options
to clear TinyDB and load the file from Media.

The Save button is not enabled until the entered mileage exceeds the old mileage.

ABG

Retrieved mileage.PNG
blocks.png
mileage_tracker.aia

Marcos_Paulo

unread,
Mar 18, 2019, 2:31:29 PM3/18/19
to MIT App Inventor Forum

Hello TimAI2

Would you help?
On their models attached, and almost what I need.
In the variable "equipment_List" has to be a table.CSV, as would be the variable scheduling looking for table.csv.

Thankful

TimAI2

unread,
Mar 18, 2019, 3:02:44 PM3/18/19
to MIT App Inventor Forum
Just substitute the equipment_list example csv list with a file component reading in the actual csv, in the file1.gottext run what is in screen.initialise

Marcos_Paulo

unread,
Mar 18, 2019, 3:25:08 PM3/18/19
to MIT App Inventor Forum
Hi,

Can you pass an example as blocks?


TimAI2

unread,
Mar 18, 2019, 6:56:16 PM3/18/19
to MIT App Inventor Forum
Something like this:
(not tested, csv in assets in blocks)

blocksreplacevariablewithfile.png


Marcos_Paulo

unread,
Mar 22, 2019, 7:04:02 AM3/22/19
to MIT App Inventor Forum
This previous procedure did not work, nothing appears in the listpickers.

You have asked not to use the variable "equipment_list", but you are not finding the table.csv file.

thankful
Reply all
Reply to author
Forward
0 new messages