Skip to content

Instantly share code, notes, and snippets.

@keum
Last active July 5, 2019 18:46
Show Gist options
  • Save keum/6590282 to your computer and use it in GitHub Desktop.
Save keum/6590282 to your computer and use it in GitHub Desktop.
Python Code using CSV & urllib for import csv STEP 1.
#Import CSV file from URL that has latest CSO status with location names and status
#This script only displays on the screen. Need to create list data into a file format.
#STEP 1
import csv
import urllib
#URL address that contains cso status with location name. This includes king county and SPU's data
url = "http://your.kingcounty.gov/dnrp/library/wastewater/cso/img/CSO.CSV"
webpage = urllib.urlopen(url)
datareader = csv.reader(webpage)
#Creating empty list to be inserted.
data = [ ]
for row in datareader:
data.append(row)
print data
#This code is to read CSV file that has location name and coordinates of longitude and latitude
#and create into dictionary table and print...
import sys
import csv
import pprint
handle = open(sys.argv[1])
reader = csv.DictReader(handle)
location = list (reader)
handle.close()
pprint.pprint(location)
@keum
Copy link
Author

keum commented Jul 5, 2019

thanks @JGruettner! I've updated the code to be run in-house system and has ported over to Python 3 and had to change the urllib as you mentioned above. I should go ahead and update the code in the repos soon. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment