import and combine list of list from csv file

67 views
Skip to first unread message

ced285

unread,
Oct 22, 2019, 12:26:03 PM10/22/19
to mitappinv...@googlegroups.com
hello everybody,

The application (princip): 
First of all the attached file is an example file to try to solve the problem raised.

Then, The main application will use an NFC tag to count the number of turns a person makes: name1 makes 3 turns, everything is scanned by the main application (master) and stored in the "startlist" Name1 | 2 laps (name1 2).

As there will be many students, a second person (or third, fourth ...) can also scan the race on another device (slave). It will also have another result with the same Name1, for example 2 laps but may also be able to scan a student who will never be passed on the main application. (name4 in my example)

The idea at the end of the race is that the slave device exports a CSV file (csvlist) which will be imported into the master application and combined with the list already in this device (starlist).

As the access to the network is fluctuating it seems to me more relevant to go through a csv file for the transfer of a device to the other than storage on a cloud ...

My problem is this: I have a list composed of another list of 2 items: the name and the score
Name1 | 1
Name 2 | 3

1.png


This list is present in the application (starlist).
I want to suggest to the user to be able to import a csv file (csvlist) with the original list of the application and combine them with the original list and the csv to have a single list. (in listview3)

2.png


In practice, if the name in the CSV does not exist in the application, then I record it with its score in the common list 'listview3'.
More complicated, if the name exists, then I do not add it (not to have 2 times name1 in listview3) but I just want to add his score. In the example, I should end up in listview3 with:

name1 | 3
name2 | 8
name3 | 4
name4 | 4

3.png



I tried to create a procedure to check if the csv team was present in the application (I get the names of the starlist and those of the csv list and I look if the items 1 of the csv are present in the starlist ...), it works but I can not go further after the verification procedure ...

If you can help me unlock this code, I will be very happy.

Thanks for the time spent reading this message ...
Ced

NB: this code will finalize a free application to help teachers manage and set up a solidarity race (the score of children turning into money according to the sponsor). I want to multiply the control points (400 students) and combine the results into a single list to facilitate management and gain speed.
blocks (1).png
combinetList.aia

TimAI2

unread,
Oct 22, 2019, 3:19:14 PM10/22/19
to MIT App Inventor Forum
What are the numbers for in "startlist" - e.g. name1 / 2, name2 / 3   ....?

ced285

unread,
Oct 22, 2019, 3:32:34 PM10/22/19
to MIT App Inventor Forum
This is the number of laps for name1 for example.

TimAI2

unread,
Oct 22, 2019, 5:31:32 PM10/22/19
to MIT App Inventor Forum
I'm confused, just do not understand what you are trying to do
If the number of laps is in the "startlist", and the score (number of laps?) a different number, is in the "csvlist".....

ced285

unread,
Oct 23, 2019, 3:39:01 AM10/23/19
to mitappinv...@googlegroups.com
Hello TIM. I will try to be clearer.

First of all the attached file is an example file to try to solve the problem raised. I took your previous file on the export csv. For convenience the CSV is created during the opening of the application, again it is for the example

Then,
The main application will use an NFC tag to count the number of turns a person makes:
name1 makes 3 turns, everything is scanned by the main application (master) and stored in the "startlist"
Name1 | 2 laps (name1 2).

As there will be many students, a second person (or third, fourth ...) can also scan the race on another device (slave). It will also have another result with the same Name1, for example 2 laps but may also be able to scan a student who will never be passed on the main application. (name4 in my example)

The idea at the end of the race is that the slave device exports a CSV file (csvlist) which will be imported into the master application and combined with the list already in this device (starlist).

As the access to the network is fluctuating it seems to me more relevant to go through a csv file for the transfer of a device to the other than storage on a cloud ...

I hope that it's clearer ?

TimAI2

unread,
Oct 23, 2019, 4:59:49 AM10/23/19
to MIT App Inventor Forum
If you have two devices scanning the same person as they take turns/laps, and the results for that person are different from each device, what happens then when you combine the data ?
Why would a person be scanned and not passed to the main app ?

You should use real names to reduce confusion so instead of name1 use David, name2 use Susan

ABG

unread,
Oct 23, 2019, 1:34:32 PM10/23/19
to MIT App Inventor Forum
If you have 400 control points (places to log the passing of a runner),
your data should be in 3 columns:
  1. timestamp (milliseconds)
  2. runner ID
  3. control point number
Each time a runner passes a control point, the data collector at that point
should add a row to his local table with the current time, the runner ID,
and that control point number.

After the race, merge the local devices' tables into a
central Google Sheet by row insertion at the end, then
sort the central table by runner ID and timestamp.

To calculate number of control points passed per runner, 
run a SQL SELECT runnerID, COUNT(control_point) GROUP BY runnerID

ABG

ced285

unread,
Oct 24, 2019, 2:09:50 AM10/24/19
to MIT App Inventor Forum
Thank you for your answers
@ timAI 2: if I add the 2 lists I have, with names>
(David 2)
(Susan 3)
(Max 4)
(David 1)
(Susan 5)
(Tim 4)

I wish to arrive at:
(David 3)
(Susan 8)
(Max 4)
(Tim 4)


@ ABG: It's a good idea, but the app cited already exists, I just want to add this extra feature. What happens in "real" situation:
- No internet access
- 400 students (not checkpoint)
- When a student arrives, he is scanned (NFC), his score is incremented each turn.
-Problem: sometimes several students arrive at the control point at the same time and wait before being scanned = loss of time, break in the race >>> Solution found: make different corridors to be scanned. Only one student will go where there will be room, it will be scanned by the device 1, 2, 3 or 4.
That's what we did and it works well. On the other hand the processing of the results is more complicated: one recovers all the csv and one manually combines the results in an excel file to make the general classification. I want to automate this phase by choosing a device ("master") which will be responsible for compiling all the csv in a single file ...

What is problematic, is the combination of the lists with the addition of new and updated score already present .. (as in my post 1 and in my combinetList.aia)

Thank you...

TimAI2

unread,
Oct 24, 2019, 5:24:24 AM10/24/19
to MIT App Inventor Forum
I think I now understand what is going on. Here is my attempt to combine the scores for three collection points:

blockscombininglists.png


screencombininglists.png



TimAI2

unread,
Oct 24, 2019, 5:58:29 AM10/24/19
to MIT App Inventor Forum
Here is an aia project of the blocks above
combinelisttotals.aia

ced285

unread,
Oct 24, 2019, 12:57:10 PM10/24/19
to MIT App Inventor Forum
Super tim it works perfectly! I revolved around the result for a while but thanks to your example I understood my error in the line:
for each name then in for each nameandscore ...
Thanks again.
I post the image of the original blocks with your contribution!
Thanks to you the setting up of a solidarity race will be facilitated for the organizers. This year the aid will go directly to Chad (I hope we will have plenty of donations). Thank you for your help and thank you to ABG!
Ced

blocks (2).png

TimAI2

unread,
Oct 24, 2019, 6:30:21 PM10/24/19
to MIT App Inventor Forum
Pleased it works for you
Reply all
Reply to author
Forward
0 new messages