python - IOError: [Errno 2] No such file or directory: 'CHTR_trades.csv' -
i appreciate help simple code:
import csv open('chtr_trades.csv','rb') csvfile: chtrreader = csv.reader(csvfile, delimiter = ' ', quotechar = '|') row in chtrreader: print ', '.join(row)
i receiving error:
traceback (most recent phone call last): file "/home/peter/pycharmprojects/practice/reader.py", line 4, in <module> open('chtr_trades.csv','rb') csvfile: ioerror: [errno 2] no such file or directory: 'chtr_trades.cs
i checked location of file terminal , in right folder:
peter@peter-hp-g60-notebook-pc:~/pycharmprojects/practice$ ls chtr_quotes.csv chtr_stdev.csv graph.py plot.py practice.py chtr_quotes.short.csv chtr_trades.csv matplotlibrc practice1.py reader.
any help appreciated.
the error telling python not have plenty info find file. can prepare problem supplying total path1:
with open(os.path.expanduser('~/pycharmprojects/practice/chtr_trades.csv'),'rb') csvfile:
or, utilize os.chdir
, alter python's current working directory:
from os import chdir os.chdir(os.path.expanduser("~/pycharmprojects/practice/")) open('chtr_trades.csv','rb') csvfile: ...
either way, need give python more info file is.
1in both of code examples above, os.path.expanduser
used expand ~
in filepath home directory.
python ubuntu
No comments:
Post a Comment