Created
May 5, 2012 01:43
-
-
Save waldoj/2599024 to your computer and use it in GitHub Desktop.
Learning Python
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
# 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 |
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
$ 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