Hello everyone, have a nice day ahead! I just want to ask some help with regards to filtering list of list. I have two list. The first list(Survey List) contains the list of all the added lists to TinyDB. The second list(Import List) contains the lists that I will going to import to TinyDB. Here is the scenario: I will click a button to pick a CSV file from phone's internal storage. The picked CSV file will be imported to TinyDB. But before adding the data of the picked CSV file to tinyDB, I want to filter each content of it to check whether it already exists in the tinyDB. My problem is the item in CSV file still added to tinyDb even if it already exists in the tinyDB. I made a lot research in the community but nothing seems to work for my app. Hoping for your kind response and thank you in advance.
Also, where do you read your File and catch the read result?
Using a display element .Text value as an intermediate calculation value is inadvisable. Their CRLFs change behind the scenes, and they can experience delays in their updates.
The green = block can compare entire lists.
It is more robust to compare internal representations than external representations.
Hello @ABG , I am sorry that I can't post my aia file since it includes a paid extension, a rule made by the developer of the extension as far as I remembered.
Could you do individual Download Blocks Images on your procedures and events, and upload them here without passing them through any editting process?
That would allow us to import those into our Blocks Editor alone.
I see a place in your Evaluate procedure where you compare a list against '[]'.
It is better to stay within the list data types and blocks.
Avoid switching to text formats of your lists, for comparisons.
or,
make a copy of your project, remove the paid extension, then upload the aia.
No paid extension needed for this 'import csv to tinydb' function i think.
I user Clock Timer block so that the if statement will be executed one by one within the specified time interval. The scenario is I will loop through each item in the import list. I will compare each item of import list to each item of survey list for me to be able to know if import item is already in survey list.
I read my CSV file from Downloads folder of the internal storage of my phone.
Oh, I see.. Thank you for this info, I don't know all about this before.
Yes, I can. Here is my sample CSV file to be imported to tinyDB. sampleCSV.csv (94 Bytes)
I tested both your suggestion @ABG and @Kevinkun and I really appreciate you for spending time to share your knowledge to me. I marked this post as solution as this solved my problem. The list item is not imported to database when it already exists. Thank you so much and God bless you all.
I have observed that whenever I export the contents of TinyDB into CSV file, each item in list is separated by square brackets and double quotes, and because of that, when I am going to import the exported CSV file back into the app once again, I will clear the unnecessary square brackets and double quotes and format the list as list from csv table.
Backend of TinyDB is a plain text file stored in your phone.
If you store a list in TinyDB, It will convert to like ["aa",123]. When you retrieve the value back, it will has square brackets and double quotes on strings (this data format called jsonArray). You need to change it to csv format with block "LIST TO CSV TABLE" if needed.