-1
I am trying to read the amount of repetitions in column A and B of a CSV and see the amount of times A and B are equal as the example below:
input:
[email protected] | [email protected]
[email protected] | [email protected]
[email protected] | [email protected]
[email protected] | [email protected]
[email protected] | [email protected]
[email protected] | [email protected]
output:
[email protected] | [email protected] | 2
[email protected] | [email protected] | 2
[email protected] | [email protected] | 1
[email protected] | [email protected] | 1
import csv
import collections
with open(r"grafo.csv") as f:
csv_data = csv.reader(f,delimiter=",")
count = collections.Counter()
for row in csv_data:
address = row[0]
count[address] += 1
for address, nb in count.items():
if nb > 1:
print('{} é um endereço duplicado, visto {} vezes'.format(address, nb))
else:
print('{} é um endereço exclusivo'.format(address))
The code above was taken from the Internet, but it only takes the amount of repetitions from a single column.
after the CSV is processed I want q it generates another CSV that contains a C column that shows the amount of repetitions