I've just started to learn python. I'm curious about what are the efficient ways to count the occurrence of a specific word in a CSV file, other than simply use for loop to go through line by line and read.
To be more specific, let's say I have a CSV file contain two columns, "Name" and "Grade", with millions of records.
How would one count the occurrence of "A" under "Grade"?
Python code samples would be greatly appreciated!
import csv; count = sum(1 for row in csv.dictreader(open(filename)) if row['Grade'] == 'A')