Skip to content

Instantly share code, notes, and snippets.

@89465127
Created March 29, 2013 20:25
Show Gist options
  • Save 89465127/5273390 to your computer and use it in GitHub Desktop.
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.
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