Skip to content

Instantly share code, notes, and snippets.

@craigcalef
Created September 29, 2018 02:17
Show Gist options
  • Save craigcalef/f2e801250a44096b5f055e6f3a9f0637 to your computer and use it in GitHub Desktop.
Save craigcalef/f2e801250a44096b5f055e6f3a9f0637 to your computer and use it in GitHub Desktop.
import csv
import pprint
with open('salesdata.csv', 'r') as f:
cars = [{k: v for k, v in row.items()} for row in csv.DictReader(f, skipinitialspace=True)]
fords = filter(lambda x: x['Make'] == 'FORD', cars)
v8 = filter(lambda x: '5.8' in x['Engine'], fords)
zips = open('zips.txt', 'r').read().strip().split(',')
local = filter(lambda x: x['Location ZIP'] in zips, v8)
if local:
pprint.pprint(local)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment