Skip to content

Instantly share code, notes, and snippets.

@eloyz
Created January 17, 2013 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eloyz/4554495 to your computer and use it in GitHub Desktop.
Save eloyz/4554495 to your computer and use it in GitHub Desktop.
Using Python to read CSV file into list.
import csv
def csv_to_list(file_path):
"""
Reads csv file into list.
"""
with open(file_path, 'rb') as f:
# load all data into memory, scary
dialect = csv.Sniffer().sniff(f.read(1024))
f.seek(0) # reset cursor
csv_list = list(csv.reader(f, dialect))
return csv_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment