Created
March 29, 2013 20:25
-
-
Save 89465127/5273390 to your computer and use it in GitHub Desktop.
Uses csv.DictReader and StringIO to read a sample csv file. No external file is required.
This file contains hidden or 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 csv | |
import StringIO | |
# cStringIO is faster, but cannot handle unicode characters | |
def main(): | |
f = StringIO.StringIO('language,greeting\nenglish,hello\nspanish,hola') | |
for _dict in csv.DictReader(f): | |
print _dict | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment