Reading in file from disk into variables
Posted: Wed Mar 24, 2021 6:38 pm
I'd like to read in a CSV file, and store/update the data in variables. I' know how to store it (thanks to these forums), but I don't know now to read it in. I'm trying:
While the code isn't working, I'm not sure if it's the CVS import code, or that I can't read from my own home directory.
What are the restrictions on reading from disk?
- Code: Select all
import csv
with open('/Users/dstrickler/Sites/indigo/weathercat.csv', newline='') as csvfile:
handle = csv.reader(csvfile, delimiter=',', quotechar='|')
for row in handle:
print(', '.join(row))
# import into variables
While the code isn't working, I'm not sure if it's the CVS import code, or that I can't read from my own home directory.
What are the restrictions on reading from disk?