Create an inventory file with Product, Quantity. TinyDB? File?

Hi There!
I need to create a simple app that reads 2 fields on screen: Product ID, Quantity
and stores these pairs "somewhere".
Then at the end of the process (this could be 3000 scanned items for an inventory) I need to dump all the records to a CSV file. Also I need a button to delete last entry so there should be an easy to use function for this on whatever method is picked.

Should I start creating a file and just appending label1.text+","+label2.text?
Or should I use a TinyDB with tags using incremental numbers and letter for each field?
Like tag "1A" contains product_1, tag "1B" contains Amount_1.
Tag "2A" contains product_2, tag "2B" contains Amount_2...
tag 3000A...tag 3000B....

And then build the CSV file with all the created tags?
Or will it be better to forget about DB's and start directly with real local files? I fear that dea,ling with removing the last record might be complex, but then dumping the final file wiill be immediate

Thank you in advance!

I would add to a list, save that list to a tinydb tag, then eventually export the list from the tinydb to a csv file when you need the csv file updated. Lists/tinydb will work much faster, save out to file as often as you feel is necessary ...

So the "value" field in the DB would be a list? Im having issues with that, complaining about wrong arguments...
Im probably missing something I can't find...


See here:

If you want to add both Product ID and Quantity to the same sublist, use a make a list block to add to the list listaPar

I had already checked that and in some way used part of that sample code, but I ALWAYS get that error, no matter what I changed. But now I simplified it and still get the same error: image

Can't I just biuld the list and assign it to the stored value without having to store it previously in a variable? This is how Im doing it in the last screenshot I pasted. But still not working

Like this:


If you want to maintain a counter, then you would need to include the number in the sublist as well

If it helps: Index Generator

Ok let me try that, THANKS!

and to remove the last item:


1 Like

Hey it's all working fine now. I still have lots of functions to prepare but you helped me a lot at this stage.

Thanks a lot!

If you want to skip using the list, and just work with the tinydb, use the index generator procedure to create your tags with a list of the data. Button1 saves a new entry, Button2 deletes the last entry


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