I have a csv file in that file I need to counter the occurrence of the string.
for example this is a sample file
column_A
Abhi
Spidy
Abhi
Max
so in the above csv file I need to have to following the output:
output:
Abhi 2
Spidy 1
Max 1
Hi have tried with this
import csv
import collections
data = collections.Counter()
print(data)
with open('file.csv') as input_file:
for row in csv.reader(input_file, delimiter=';'):
data[row[1]] += 1
print('%s' % data['columnA'])
print(data.most_common())
row[0]if you want the first column, indexes start at0not1