Last active
March 12, 2016 04:40
-
-
Save clbarnes/ca899f1355f49090ab2e to your computer and use it in GitHub Desktop.
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
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
1 | |
2 | |
3 |
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
[ | |
1, | |
2, | |
3 | |
] |
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
“NUMPY F {'descr': '<i4', 'fortran_order': False, 'shape': (3,), } | |
sjbgojsnbgsdhngodshnfgopsnogisdgnsobgis |
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
your_list = [1, 2, 3] | |
# using csv module | |
import csv | |
# write it | |
with open('list.csv', 'w') as f: | |
writer = csv.writer(f) | |
writer.writerows(your_list) | |
# read it | |
with open('list.csv') as f: | |
reader = csv.reader(f) | |
your_list2 = list(reader) | |
# using json | |
import json | |
# write it | |
with open('list.json', 'w') as f: | |
json.dump(your_list, f, indent=2) # the indent argument isn't necessary, just makes it easier for humans to read the file | |
# read it | |
with open('list.json') as f: | |
your_list2 = json.load(f) | |
# using numpy | |
import numpy as np | |
# write it | |
np.save('list.npy', your_list) # creates a file which can't be read by humans but numbers are full precision | |
# read it | |
your_list2 = np.load('list.npy') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment