python - os.path.isfile raises FileNotFoundError -


im trying little python script moving few files destination given in .xlsx file. im using os.path.isfile method.

from openpyxl import load_workbook os.path import basename, dirname, exists, isfile os import rename    wb = load_workbook(filename = 'list.xlsx') tbl1 = wb['tabelle1'] = 2 entry = tbl1['b{}'.format(i)].value while not entry == none:     entry = tbl1['b{}'.format(i)].value     if isfile(basename(entry) + ' (2)'):         print("datei doppelt vorhanden")         += 1         continue     if isfile(basename(entry)):         print("verschiebe {}".format(basename(entry)))         rename(basename(entry),'u:\\' + dirname(entry)[33:] + '/http_download/' + basename(entry))         += 1 

when run script not print i have stop using ctrl + c. idle shows me isfile raises filenotfounderror seems kinda weird.

error:

traceback (most recent call last):   file "c:\users\user\appdata\local\programs\python\python35\lib\genericpath.py", line 30, in isfile     st = os.stat(path) filenotfounderror: [winerror 2] das system kann die angegebene datei nicht finden: 'interview_jahn.flv'  during handling of above exception, exception occurred:  traceback (most recent call last):   file "y:\censored\flv-mp4-codierung\neucodier_script.py", line 17, in <module>     if isfile(basename(entry)):   file "c:\users\user\appdata\local\programs\python\python35\lib\genericpath.py", line 30, in isfile     st = os.stat(path) keyboardinterrupt 

this infinite loop, , entry never none

while not entry == none:     entry = tbl1['b{}'.format(i)].value     if isfile(basename(entry) + ' (2)'):     ... 

when breaking, keyboardinterrupt interrupts (catched) exception handling embedded in isfile() (which uses os.stat internally, , catches exception, normal when file doesn't exist).

the error message "during handling of above exception, exception occurred" doesn't otherwise. primary problem here infinite loop end.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -