Skip to content

Instantly share code, notes, and snippets.

@jwtea
Created May 27, 2014 19:41
Show Gist options
  • Save jwtea/f17ecbf64aa1f307a34c to your computer and use it in GitHub Desktop.
Save jwtea/f17ecbf64aa1f307a34c to your computer and use it in GitHub Desktop.
data = {}
with open("C:/Python27/pythoncbr/data/"+filename,"rb") as f:
reader = csv.DictReader(f)
for row in reader:
if row['Customer ID'] != "":
key = row['Customer ID']
data.setdefault(key, [])
data[key].append(row['prodID'])
if row['Customer ID'] == "":
data[key].append(row['prodID'])
return data
Data in excel is like this
Cust id, prod id, amount, stockist type
c1 p1 100 large
p2 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment