I have a huge CSV where each line has a user ID. I want to find the UserID that turns up most frequently across the whole set.
I've used DictReader
from the csv
module to read in the csv, as I think this will be most useful to manipulate individual records later.
I can't find a way to search through the various values for the key "UserID" in my created dictionary and find the most frequent value.
Any help would be greatly appreciated!
Here is my code so far:
import csv
from time import time
start = time()
myData=open("myCSV.csv", "rb" )
csvReader= csv.DictReader(myData)
# declare counters
volume = 0
#sum all data usage
for data in csvReader:
volume += float(data["volume_total"])
print "Total : %f" %volume
#calculate processing time
elapsed = time() - start
print "Processing time: %f seconds" %elapsed