I have a large CSV file with 4 columns (date, name1, name2, amount):
Example:
1/12/13 12:29 Artem Boris 80
1/12/13 12:31 Boris Duane 81
1/12/13 12:29 Robert Richard 70
1/12/13 12:29 Michael Eric 149
1/12/13 12:29 Richard Michael 80
1/12/13 12:34 Boris Artem 150
1/12/13 12:38 Artem Michael 151
I want to process the file and get the following another CSV file as output:
Date Name 1 Name 2 Amount Chain ID
1/12/13 12:29 Artem Boris 80 1
1/12/13 12:31 Boris Duane 81 1
1/12/13 12:34 Boris Artem 150 2
1/12/13 12:38 Artem Michael 151 2
1/12/13 12:29 Michael Eric 149 2
The python code should look through the input file, find pairs of records where Name2=Name1 AND (difference in amount <= 1) AND (difference in date <= 10 minutes), and assign all such pairs with a unique ID in the output file. Pairs can be triples (like in the example above for chain ID=2), or longer chains.
I want Python 3.4 compatible code.
Please a.d.d Me S.k.y.p.e I.d---jolip05 for more discus
*********************************************************************************************************