Created
December 7, 2013 03:29
-
-
Save rob-smallshire/7836933 to your computer and use it in GitHub Desktop.
Read a CSV file into a dictionary of lists, using the column names in the first row as dictionary keys mapping to lists of numeric column data taken from subsequent rows in the CSV file.
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 | |
with open('faithful.dat', newline='') as csvfile: | |
reader = csv.reader(csvfile, quoting=csv.QUOTE_NONNUMERIC) | |
names = next(reader) | |
columns = zip(*reader) | |
data = {name: column for name, column in zip(names, columns)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment