1
파일 이름을 전달하면 파일을 열 수있는 스크립트가 생겼으나 이제는 파일 수가 늘어나고 각 파일에서 스크립트를 실행해야합니다. 개별적으로 그래서 파이썬이 디렉토리에서 al 파일을 읽게하기로 결정했습니다. 이에서Python XLRD에 해당 파일이나 디렉토리가 없습니다.
for root, dirs, files in os.walk("Approved_LRPMP_Worksheets/"):
for fyle in files:
if fyle.endswith(".xlsx"):
print fyle
book = xlrd.open_workbook(fyle)
print "book opened"
출력은 다음과 같습니다
I found a file: Agoura Hills LRPMP Review Sheet.xlsx
Traceback (most recent call last):
File "test.py", line 21, in <module>
book = xlrd.open_workbook(fyle)
File "/Library/Python/2.7/site-packages/xlrd/__init__.py", line 394, in open_workbook
f = open(filename, "rb")
IOError: [Errno 2] No such file or directory: 'Agoura Hills LRPMP Review Sheet.xlsx'
파일은 명확하게 읽고있는 파일의 이름은 내가 오류를 얻으려면, 그 전에 명령 행에서 출력됩니다. 나는 이것이 내가 잡아야 만하는 단순한 것 같은 느낌이 든다. 그러나 그것은 지난 30 분 동안 나를 피했다. ...