Bernard Rankin wrote:
I've got several versions of code to here to generate a histogram-esque
structure from rows in a CSV file.
The basic approach is to use a Dict as a bucket collection to count
instances of data items.
Other than the try/except(KeyError) idiom for dealing with new
The simplest. That would be #3, cleaned up a bit:
from collections import defaultdict
from csv import DictReader
from pprint import pprint
from operator import itemgetter
def rows(filename):
infile = open(filename, rb)
for row in DictReader(infile):
yield
Hello,
I've got several versions of code to here to generate a histogram-esque
structure from rows in a CSV file.
The basic approach is to use a Dict as a bucket collection to count instances
of data items.
Other than the try/except(KeyError) idiom for dealing with new bucket names,
which I