Created
January 17, 2013 08:17
-
-
Save eloyz/4554495 to your computer and use it in GitHub Desktop.
Using Python to read CSV file into list.
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 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