Skip to content

Instantly share code, notes, and snippets.

@waldoj
Created May 5, 2012 01:43
Show Gist options
  • Save waldoj/2599024 to your computer and use it in GitHub Desktop.
Save waldoj/2599024 to your computer and use it in GitHub Desktop.
Learning Python
# Import needed libraries.
import csv, urllib2
# Retrieve the contents of the CSV report file
csv_file = urllib2.urlopen('http://www.sbe.virginia.gov/sbe_csv/CF/Report.csv').read()
# Convert the contents of the CSV file to a list.
# (Shouldn't this use a try / except?)
Report = csv.reader(csv_file)
# Iterate through the report and display each line, joined by commas.
for row in Report:
print row
$ python sbe-parser.py
['\nR\ne\np\no\nr\nt\nI\nd\n']
['', '']
['\nA\nc\nc\no\nu\nn\nt\nI\nd\n']
['', '']
['\nC\no\nm\nm\ni\nt\nt\ne\ne\nC\no\nd\ne\n']
['', '']
['\nC\no\nm\nm\ni\nt\nt\ne\ne\nN\na\nm\ne\n']
['', '']
['\nC\no\nm\nm\ni\nt\nt\ne\ne\nT\ny\np\ne\n']
['', '']
['\nC\na\nn\nd\ni\nd\na\nt\ne\nN\na\nm\ne\n']
['', '']
['\nI\ns\nS\nt\na\nt\ne\nW\ni\nd\ne\n']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment