I wanted to make an app for a charity run where about 250 drivers will take part.
All driver information (ID, name, given name) are available in a .csv. Via the "Admin -> Import" buttons I can already retrieve the data, but it isn't stored to the tinyDB when i want to show all drivers via "Admin -> Driver" menu.
If I add a new driver manually all information is stored correctly. This is the first issue...
When the race starts the driver should enter his ID and the app should tell him his/her name so he/she can check if it's right. This works fine. The there are two buttons "Start" & "End" which create a time stamp, these values should be added to their tinyDB entry. it works.. but not the way I wanted it. Hitting one of the two buttons adds the value but messes up the record which will then look like name: (((Doe john ) 05:39:52 ) 05:40:51 ) instead of writing the different values to the according fields.
Last issue is that I need to export the tinyDB to a .csv and mail it to an email address so we can take the list and calculate the needed time from start to end in Excel or LibreOffice.
As this is my very first app I guess many of the solved problems could have been done better, but at least it works... somehow...
I would really appreciate your help and suggestions, so if anybody could help me with the last issues I'd be very happy. I searched a lot in the forum and found many solutions but still no ones which could fix the last issues.
All driver information (ID, name, given name) are available in a .csv. Via the "Admin -> Import" buttons I can already retrieve the data, but it isn't stored to the tinyDB when i want to show all drivers via "Admin -> Driver" menu.
If I add a new driver manually all information is stored correctly. This is the first issue...
When the race starts the driver should enter his ID and the app should tell him his/her name so he/she can check if it's right. This works fine. The there are two buttons "Start" & "End" which create a time stamp, these values should be added to their tinyDB entry. it works.. but not the way I wanted it. Hitting one of the two buttons adds the value but messes up the record which will then look like name: (((Doe john ) 05:39:52 ) 05:40:51 ) instead of writing the different values to the according fields.
Last issue is that I need to export the tinyDB to a .csv and mail it to an email address so we can take the list and calculate the needed time from start to end in Excel or LibreOffice.
As this is my very first app I guess many of the solved problems could have been done better, but at least it works... somehow...
I would really appreciate your help and suggestions, so if anybody could help me with the last issues I'd be very happy. I searched a lot in the forum and found many solutions but still no ones which could fix the last issues.
--
Please post a screenshot of the relevant blocks (the parts where you need help with) such as the timestamp saving on TinyDB.
Abraham made this app to export TinyDB data ai2.appinventor.mit.edu/?galleryId=6019316599488512
You can also search the forum for "TinyDB to csv". That's how I found it.
These are the results I got when searching:
--
The first is how I retrieve the timestamp, the second picture is how i wanted to import from .csv. I attached the whole project file to my initial post so you can see what's happening and what's wrong.
I tried Abraham's app but can't find out where to place my .csv to use it. Thanks for the search link, I tried it this way but only found a lot of questions and no example that worked for me.
I tried Abraham's app but can't find out where to place my .csv to use it. Thanks for the search link, I tried it this way but only found a lot of questions and no example that worked for me.
--
I don't see the blocks where you retrieve the name, the given name and the time from the list saved in your TinyDB under the tag made with the ID.
All I see is the block where you retrieve the list of names, when the btnAddItem is clicked.
Please post a screenshot of that too.
--
There are at least two errors in how you are saving start and end times.
1. You fail to retrieve the record for the current driver from TinyDB immediately before updating it, thus making it impossible to preserve the start time when you store the end time.
2. You reuse column 3 of the record for the end time when you store the end time. You wanted it in column 4, not column 3, right?
3. On the other hand, you keep separate columns for name and given name, in addition to ID in column 1, so your start and end times should be in (counting mentally), columns 4 and 5 respectively?
I tried Abraham's app but can't find out where to place my .csv to use it.
See the last entry in the Files section of this FAQ ...
Also see the note on output file placement on the sdcard in the tool tip for the Files block that writes files.
--
--
You fail to retrieve the record for the current driver from TinyDB immediately before updating it, thus making it impossible to preserve the start time when you store the end timeHow do I retrieve the record correctly?
See attached for how to get elapsed minutes between Start and End times.Thank you so much for this example but when i include it in my app i get this error code:
See attached for how to get elapsed minutes between Start and End times.Thank you so much for this example but when i include it in my app i get this error code:
Argument to MakeInstant should have form MM/DD/YYYY hh:mm:ss, or MM/DD/YYYY or hh:mm<br/><i>Note:</i> You will not see another error reported for 5 seconds.
--
In case you run out of time to make your app before the race,
--
here's a fallback approach ...
Bring along a fully charged laptop loaded with your spreadsheet and your
spreadsheet program, and use the key combination that
(This might vary from program to program.)
We found some voluenteers who will type in all 250+ drivers by hand on all three devices, so the import part is no major problem any more.... Would have been great if it could be managed by the .csv import, but it seems I've got no luck with this.
But I'd be very happy/thankful if someone could help me with the right handling of the "driver" screen.
The issue is still, that I overwrite the TinyDb fields in the wrong way. The value TOverall, the calculated time is also no major part anymore. We will count this in a Excel sheet. I guess i'll manage it to export the tinyDB to .csv.
as seen above the whole App is included as an attachment.
Values that are needed to be saved via "Admin -> AddDriver" and modified via "Driver" to tinyDB:
txtID: ID (numbers only, e.g. 012)
txtName: Name (e.g. Doe)
txtGivenName: Given name (e.g. John9
TStart: Start Time (will be modified via "Driver" "Start", gets local time from device, works already but is saved in the wrong field, eg: 09:15:37)
TEnd: End Time (will be modified via "Driver" "Finsih", gets local time from device, works already but is saved in the wrong field, eg: 11:23:42)
Thanks to all the people especially Abraham who gave me so much help so far.
charity_run_2.aia
But I'd be very happy/thankful if someone could help me with the right handling of the "driver" screen.
The issue is still, that I overwrite the TinyDb fields in the wrong way. The value TOverall, the calculated time is also no major part anymore. We will count this in a Excel sheet. I guess i'll manage it to export the tinyDB to .csv.
as seen above the whole App is included as an attachment.
Values that are needed to be saved via "Admin -> AddDriver" and modified via "Driver" to tinyDB:
txtID: ID (numbers only, e.g. 012)
txtName: Name (e.g. Doe)
txtGivenName: Given name (e.g. John9
TStart: Start Time (will be modified via "Driver" "Start", gets local time from device, works already but is saved in the wrong field, eg: 09:15:37)
TEnd: End Time (will be modified via "Driver" "Finsih", gets local time from device, works already but is saved in the wrong field, eg: 11:23:42)
Thanks to all the people especially Abraham who gave me so much help so far.
charity_run_2.aia
Ok.... solved the issues with the wrong fields.... Everything works fine now. ID, name, given name, start & end time are saved in the right fields, the overall time is calculated just as I wanted it. No broken TinyDB fields any more :)
If someone could help me with an tutorial for export from tinyDB to .csv it all would be done and i'd be just in time for the race :)
Maybe I can fix the import from .csv to TinyDB problem too, then it'll be perfect :)
If someone could help me with an tutorial for export from tinyDB to .csv it all would be done and i'd be just in time for the race :)
Maybe I can fix the import from .csv to TinyDB problem too, then it'll be perfect :)
--
How you convert what is in a TinyDB to a csv depends on what you save in the TinyDB and how your tags are set up.
--
I would use the list to csv table list block. If everything is stored in the TinyDB as a List,
then use the for each number from block , replacing the default '5' with length of list list where list is the List in the tag.
An example / explanation of how you finally saved your data in the TinyDB would help someone to provide perhaps more hints.
I've attached the blocks diagram. This should tell how I save the data to TinyDB. I tried the search function a lot, otherwise I wouldn't have managed to get the APPrunning so far, but I still found no example or how-to which i could modify to my needs. As most of my app was a built by reading tutorials, buying a bunch of appinventor books, modifying existing code and a lot of copy & paste as I'm a total newbie, it may look a bit confusing but it works... ;)
the exported csv should contain the existing fields txtID,txtname,txtGivenname,txtStart,txtEnd,txtOverall which are stored in a list under the TinyDB tag "txtiD". You can find this in the block "when btnSave.Click"
All I still need is this damn import(would be a great help as there are over 300 drivers that have to be added by hand otherwise...)/export (.csv to email, to import in Excel) thing to get the app ready for the charity run. I've got only two days left... :(
The complete app is in .aia format somewhere in this thread.
--
To see how to get all of TinyDB into a big block of text ready to
--
write to a file, see Dump_TinyDB and TinyDB_export_import in
Slashes look like this: /
not like Windows or MSDOS slashes \
A single / before file name should send it to SDCARD:
File Non-visible component for storing and retrieving files. Use this component to write or read files on your device. The default behaviour is to write files to the private data directory associated with your App. The Companion is special cased to write files to /sdcard/AppInventor/data to facilitate debugging. If the file path starts with a slash (/), then the file is created relative to /sdcard. For example writing a file to /myFile.txt will write the file in /sdcard/myFile.txt.
thank you Abe, the export.csv is written to the device now via the "dump example", only the output is a bit messy.... I try to find a tutorial for formatting the output now in the forum.
at the moment it looks like:
"01","(Doe John 14:33:07 16:30:17 117)"
"02","(Doe Jane 14:47:29 14:49:17 2)"
and so on.
If i'm right the .csv should look like
01,Doe,John,14:33:07,16:30:17,117
02,Doe,Jane,14:47:29,14:49:17, 2
so it works in Excel
at the moment it looks like:
"01","(Doe John 14:33:07 16:30:17 117)"
"02","(Doe Jane 14:47:29 14:49:17 2)"
and so on.
If i'm right the .csv should look like
01,Doe,John,14:33:07,16:30:17,117
02,Doe,Jane,14:47:29,14:49:17, 2
so it works in Excel
--
The List View Elements will not show a table accurately,
--
because assignment of each row (a list) into an Element (a Text)
loses the commas and adds parentheses.
What does the csv file look like?
This builds a csv table for export using a File control:
It might work for you. It contains the 'correct' formatting as far as I can tell.
The code dumps each contestant to a label, the \n makes it a table by stacking csv rows. The label becomes a variable called csvExportTable... save it with a File control as theFile.csv and you might be where you want to be.
Good luck with the activity. Your app probably will work but be aware it is untested and might crash. The code I saw shows plenty of places entry could go wrong. Have you tested this with 300 pieces of contestant data?
--
Steve, you're awesome. Thank you so much. This works almost perfect but has a small issue. whenever I do the export I get this error code:
The operation list to csv table cannot accept the arguments: , ["01,Miller,Dave,08:28:54,08:28:54,0
02,Pantz,Sandy,08:29:09,08:29:09,0
03,Scummette,Razor,08:29:25,08:29:25,0
04,Edison,Fred,08:29:43,08:29:43,0
05,Edison,Edna,08:30:06,08:30:06,0
06,Edison,Ed,08:30:25,08:30:25,0
]<br/><i>Note:</i> You will not see another error reported for 5 seconds.
and the last driver in the TinyDB misses in the export
All I added to your code was
call fil1.SaveFile
text list to csv table list get globalcsvExportTable
fileName "data.csv"
02,Pantz,Sandy,08:29:09,08:29:09,0
03,Scummette,Razor,08:29:25,08:29:25,0
04,Edison,Fred,08:29:43,08:29:43,0
05,Edison,Edna,08:30:06,08:30:06,0
06,Edison,Ed,08:30:25,08:30:25,0
]<br/><i>Note:</i> You will not see another error reported for 5 seconds.
and the last driver in the TinyDB misses in the export
All I added to your code was
call fil1.SaveFile
text list to csv table list get globalcsvExportTable
fileName "data.csv"
--
I don't know. It depends on where you placed that code. This could be a timing issue. App Inventor processes asynchronously and all the data might not be there when you SaveFile or you might have an empty slot in your blocks or the list to csv table list block is not needed because globalcsvExportTable is already a List?
--
The issue of the last driver being missing probably arises from the loop limit calculation
subtracting 2 from the number of items in the list.
Regarding that csv table conversion error message,
I did not see such a block in the Button3 export code that Steve gave you.
Maybe you should explain why and where you added such a block?
--
댓글 없음:
댓글 쓰기