Oct-10-2018, 01:20 PM
In this case I would articulate the task at hand as follows:
- how to read data on rows from different csv files into some data structure
On way of doing it is to use dictionary. Following is not exact solutions to your task but you can modify it to fit your needs:
1. Split row
2. Read data on row to dictionary where date is key and ratings are values
3. Print out dictionary
- how to read data on rows from different csv files into some data structure
On way of doing it is to use dictionary. Following is not exact solutions to your task but you can modify it to fit your needs:
1. Split row
2. Read data on row to dictionary where date is key and ratings are values
3. Print out dictionary
rows = [ '07.10.2018 10:09 3', '07.10.2018 10:31 2 2 1 1 1', '07.10.2018 10:46 2 3', '07.10.2018 10:48 1 2', '08.10.2018 12:09 6', '08.10.2018 12:31 2 2 1 1 1 2 4 6', '09.10.2018 17:46 2 3 4 5', '09.10.2018 17:48 2 3 4 5 2 3 4 5 2 3 4', '09.10.2018 17:51 2 3', '09.10.2018 17:52 3 3', '09.10.2018 18:53 1 3', '09.10.2018 19:46 2 1 1 1 1' ] data = {} for row in rows: key, _, value = row.strip().split(maxsplit=2) try: data[key].append(value) except KeyError: data[key] = [value] for key, value in data.items(): print(key, ' '.join(value))This code will output:
Output:07.10.2018 3 2 2 1 1 1 2 3 1 2
08.10.2018 6 2 2 1 1 1 2 4 6
09.10.2018 2 3 4 5 2 3 4 5 2 3 4 5 2 3 4 2 3 3 3 1 3 2 1 1 1 1
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.