[Tutor] File not found error, but it is in the folder!
Woody 544
woody544 at gmail.com
Wed Apr 10 16:44:09 CEST 2013
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
More information about the Tutor
mailing list