Created
September 8, 2014 03:28
-
-
Save kennyledet/b4f415e48621d783fe95 to your computer and use it in GitHub Desktop.
Convert a CSV file to a Javascript Array
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
def csv_to_js_array(csv_path): | |
import csv | |
import os | |
attributes = [] | |
values = [] | |
with open(csv_path, "rb") as csvfile: | |
print csvfile | |
reader = csv.reader(csvfile) | |
for row_num, row in enumerate(reader): | |
if row_num == 1: | |
attributes = row | |
else: | |
values.append(row) | |
return {"attributes": attributes, "values": values} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment