In this part of the project, .csv file contains list of unique keywords and associated onesignal id.
Each email that I receive from a private company will have any one of the keyword in its body. Unique Keyword = Unique user.
So in my phone, when Automation app 'Tasker' detect the keyword from email and check if the keyword is also in .csv file, if so then the word 'send' will be added in the next cell of the key word in .csv file.
Mit ai2 app will constantly watch for the word 'send' in the .csv file and once found , it will assign the associated onesignal id as global variable and send notification. After, sending notification the word 'send' will be deleted, and hence the loop/process will continue in this way.
How can I edit/update data in the .csv file that is in phone using Mit ai2 app? For example, If there is a word 'apple' in .csv file, then delete it automatically. Whenever I add the word Apple (manually) anywhere in the .csv file, it has to be deleted automatically.
How can I do it?
How can I edit or update data in a .csv file stored on my phone using an MIT App Inventor app? For instance, if the word 'apple' exists in the .csv file, I want it to be automatically deleted. Additionally, whenever I manually add the word 'apple' anywhere in the .csv file, it should be removed automatically.
How can I achieve this?"
I guess, this block may help.
It is a bad design choice to use a file as data storage if you have to edit data frequently, because it is cumbersome to work with files
You have to read it completely, edit what you want to edit and save it again...
The question is, why don't you use a database? Depending on the requirements this can be a local sqlite database or if several people need to access it a server database
Taifun
I am looking for the option that is free of cost forever. I was planning to use Google Sheet, but after I learned that it is not free after certain quota limit, I decided this.
I think, Sqlite database is also not free of cost forever.
But, if I choose .csv file to achieve this, I can make it totally for free of cost forever. So, I can offer apps for totally free of cost to people and play google ad in it. When I get revenue from ads, According to the revenue value, I will use the databases like sqlite or google sheet later.
For safety at beginning, I prefer to use .csv file. I think that the automation app 'Tasker' can save the file frequently whenever there is any update in it. I have to check it, not sure now.
This post was flagged by the community and is temporarily hidden.
let us know what you found out and provide a link to these Google sheet quota limits
you are wrong
Taifun
Remember, you have to use SAF to read/write non media files your app does not own, see also Some basics on Android storage system
Also you might want to think about how you plan to solve the problem of 2 processes (Tasker and your app) writing at the same time
Taifun
I Did something similar cvs file sent to GSS and deleted after being sent. Then a new file with same name sent again and appended to the GSS. But blocks where lost, after my son was intubated due to covid, but i Will recode.....i Will see if i can find my way back. I Will let you know if i can re do it.
I managed to update .csv file using Tasker in phone (for every email notification from a specific sender), Next thing is to update that same .csv file in a different way using mitai2. In this way, I think I can skip using google sheet or other databases frequently and avoid quota limit issues.
But, since sqlite is free of cost, Il use that as well in part of the app needs.
NOTE: I used Tasker (One time payment around 3 usd), Autonotification plugin (free of cost if we watch a reward ad occasionally) and fairemail (free) for watching email notifications.
Can I use Taifuns Notification listener extension to cancel the notifications one after other?
No
You could have read rhe documentation to answer this question yourself
Taifun
I read it once but asked to know if there is any possibility. Thankyou
You could try the CloudDB, Is that what you need?
CloudDB is ai2's database in the cloud that is not stored on just one instance of the app, it is stored on everyone's instance.
If that is not what you want and you want a local database that is different for everyone's device, try TinyDB.
all of these use a key/value thing.
After spending lot of time, yesterday I completed the coding part of Tasker. Now, Tasker will do the following always.
-
If email notification recieved with keyword that start with prefix key in FAIR EMAIL, Tasker will parse complete notification and store it in text file.
-
I already have .CSV file with lot of keywords and onesignal id in the next column of it. If the keywords from notification is matched with CSV file, then Tasker will provide the row number where the keyword recived in notification is matched. This row number/index will be stored in another text file.
-
Now in mit ai2, il create an app that will parse the row/index value from that text file and collect the required data from CSV file( ie, onesignal id belongs to that row) using the row/index number.
-
This collected onesignal id will be put in a gloabal variable and a message will be triggered 'You Got A New Order'. So, the right user will get this notification.
CODE THAT I CREATED IN TASKER:
Task: Temp
Settings: Run Both Together
A1: AutoNotification Query [
Configuration: Persistency Type: Both
Notification Apps: FairEmail
Get All Fields : true
Timeout (Seconds): 20
Structure Output (JSON, etc): On ]
A2: Write File [
File: Download/CSV File Viewer/hi.txt
Text: %antextbig()
Add Newline: On ]
A3: AutoNotification Cancel [
Configuration: Id: %anid
Notification Apps: FairEmail
Package Name: %anpackage
Timeout (Seconds): 20
Structure Output (JSON, etc): On ]
A4: Read File [
File: Download/CSV File Viewer/hi.txt
To Var: %textfile
Structure Output (JSON, etc): On ]
A5: Variable Search Replace [
Variable: %textfile
Search: \bkey\w*\b
Store Matches In Array: %textkeys ]
A6: Write File [
File: Download/CSV File Viewer/antextbig an.txt
Text: %textkeys()
Add Newline: On ]
A7: Read File [
File: Download/CSV File Viewer/antextbig an.txt
To Var: %textfilewithkeys
Structure Output (JSON, etc): On ]
A8: Variable Set [
Name: %newline
To:
Structure Output (JSON, etc): On ]
A9: Variable Set [
Name: %newspace
To:
Structure Output (JSON, etc): On ]
A10: Variable Search Replace [
Variable: %textfilewithkeys
Search: ,
Replace Matches: On
Replace With: %newspace ]
A11: Variable Search Replace [
Variable: %textfilewithkeys
Search:
Replace Matches: On
Replace With: %newline ]
A12: Variable Set [
Name: %text_data
To: %textfilewithkeys
Structure Output (JSON, etc): On ]
A13: Variable Split [
Name: %text_data
Splitter: %newline ]
A14: Read File [
File: Download/CSV File Viewer/2010.csv
To Var: %csv_data
Structure Output (JSON, etc): On ]
A15: Variable Set [
Name: %to_search
To: %text_data(+/)
Structure Output (JSON, etc): On ]
A16: Stop [ ]
If [ %csv_data.Header3(#?%to_search) eq 0 ]
A17: Array Set [
Variable Array: %indexes_of_matches
Values: %csv_data.Header3(#?%to_search)
Splitter: , ]
A18: Flash [
Text: %indexes_of_matches()
Continue Task Immediately: On
Dismiss On Click: On ]
A19: Variable Search Replace [
Variable: %csv_data
Search: \Q%csv_data.Header1(%first_match),%csv_data.Header2(%first_match),%csv_data.Header3(%first_match)\E
Replace Matches: On
Replace With: $0,find ]
A20: Write File [
File: Download/CSV File Viewer/hihi.txt
Text: %indexes_of_matches()
Add Newline: On ]
A21: Text/Image Dialog [
Title: Result
Text: %csv_data
Button 1: Ok
Close After (Seconds): 120 ]