Created
May 10, 2017 18:46
-
-
Save wardi/37e1d9922113a3252071665cda19b0b6 to your computer and use it in GitHub Desktop.
Download and strip newlines and double quotes from OD inventory dataset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
import requests | |
import csv | |
URL = 'http://open.canada.ca/data/dataset/4ed351cf-95d8-4c10-97ac-6b3511f359b7/resource/d0df95a8-31a9-46c9-853b-6952819ec7b4/download/inventory.csv' | |
OUTPUT = 'inventory-stripped.csv' | |
r = requests.get(URL, stream=True) | |
out = csv.writer(open(OUTPUT, 'wb')) | |
for row in csv.reader(r.raw): | |
out.writerow([ | |
c.replace('\n', '').replace('\r', '').replace('"', '') | |
for c in row]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment