I have few doc in .csv - 20 000 record or more.
Basically it's easy - something like that:
numer,produkt,date
202,produkt A its sad,20.04.2019
203,produkt A its sad,21.04.2019
204,produkt A its sad,22.04.2019
etc
I want to print info:
A "produkt A its sad" appears 6 times A "produkt B" appers 3 times A "produkt C" appers 2 times
Base on another answer on stack overflow I wrote:
import csv
from collections import Counter
with open ('base2.csv', encoding="utf8") as csv_file:
csv_reader = csv.reader(csv_file)
produkt = [row[0] for row in csv_file]
for (k,v) in Counter(produkt).items():
print ("A %s appears %d times" % (k, v))
I'm newbie on python so its probably something stupid :)
output is:
A n appears 1 times
A 2 appears 11 times
produkt = [row[0] for row in csv_file]
essentialy says read each line from the file and store as row, then take the first char of that line. You prob want to replace csv_file to csv_reader