I am in need of assistance. I have variables I can write to a .CSV file, however, it duplicates any existing variables that is written to the said file.
The blackened variables are irrelevant. I just want to see if "propertyRoster.txt" holds a match for global_getButtonName, and re-write the section of the file for those variables if so. It constantly adds the global_getButtonName (and the rest of the variable listings) whether there is a match or not. When I try creating a global variable that holds a list of variables, it complains and does not accept it.
Basically, I need to find out if getButtonName exists in the file and overwrite those six variables if there is a match, else, append the file for adding those six values. I'm doing it in this formation so when the user leaves the app and comes back, the data is still there. So if he comes back later and changes the Orange value, it can then overwrite the previously saved Orange values.
TinyDB will not work for my case, as several instances rely on these six variables altogether and I'm trying to make the app small as possible. This is why I need it saved to a file, I do not know of an efficient way to store several instances with these six values. I don't want to compose multiple files. This is what my text file looks like:
E.g. (Apple val2 val3 val4 val5 val6)(Orange val2 val3 val4 val5 val6) ...... Note: val1 is always the name of the button pressed, not included with the code.
(Note: The "/" before the propertyRoster.txt signifies it saves to an SD card.)
I cannot find anything online for my case for locating a match in a textfile or to edit that part. Please help!
Your if
statement always is false, because your variable global_get_ButtonName
is always in the list... this is probably not what you want?
btw. everything looks very cumbersome and I would use TinyDB to store data persistently...
Some Recommendations: Learn how to work with lists and list of lists
How to work with lists by Saj
How to work with list of lists (pdf) by appinventor.org
Edit: See screenshot how to find out, if a value exists in a list of lists