On 10/04/2013 15:44, Woody 544 wrote:
I have a script that worked before I moved it to another folder. I
cannot understand why I am getting a 'No such file or directory'
error, when the file is in the folder.
Any clues would be much appreciated. Thanks!
MJ
Here is a copy and paste of the script up to the error, output/error
and a check for the file:
SCRIPT:
import os, string, codecs
os.chdir('W:\\BEP\\DOS reports\\Q1 FY13\\BEP_Tool4DOS')
folder = 'W:\\BEP\\DOS reports\\Q1 FY13\\BEP_Tool4DOS\\FY13Q1_responses'
files = os.listdir(folder)
#os.walk(folder)
fy13q1dict = {'country' : 'countryname', 'title':'titlename',
'travel':'traveldata',
'publications':'pubdata','conferences':'confdata','highlights':'higlightdata','upcoming':'upcomingdata'}
countryname = ()
titlename = ()
for i in files:
fy13q1dict = {'country' : 'countryname', 'title':'titlename'}
fp = codecs.open(i,mode='rb',encoding=None,errors='replace',buffering=1)
data = str(fp.read())
data = data.replace('\xa0',' ')
data = data.split()
OUTPUT:
Traceback (most recent call last):
File "W:\BEP\DOS reports\Q1 FY13\BEP_Tool4DOS\bep_dos_tool.py", line
22, in <module>
fp = codecs.open(i,mode='rb',encoding=None,errors='replace',buffering=1)
File "C:\Python27\lib\codecs.py", line 881, in open
file = __builtin__.open(filename, mode, buffering)
IOError: [Errno 2] No such file or directory: 'Algeria_688_RVF.txt'
CHECK FOR FILE IN FOLDER:
os.listdir('W:\\BEP\\DOS reports\\Q1 FY13\\BEP_Tool4DOS\\FY13Q1_responses')
['Algeria_688_RVF.txt', 'Egypt_31060_RVFEnvir
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Your os.chdir call doesn't have the FY13Q1_responses directory on the end.
A slight aside, it's far easier to write Windows file paths with raw
strings or even use forward slashes.
--
If you're using GoogleCrap™ please read this
http://wiki.python.org/moin/GoogleGroupsPython.
Mark Lawrence
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor