При запуске кода ниже строки os.chdir(folder_path)
возвращает ошибку. Что не так?
Это моя иерархия папок:
-data
-NotaCorretagem_60076_20181009.pdf
-output
-report
-script
-data_extraction.py
Мой код файла data_extraction.py:
# import modules
from tika import parser
import pathlib as pl
import os
# list of functions
def main():
"""
Special function to invoke the functions automatically when the program is
executed.
"""
extract_pdf()
def extract_pdf():
"""
A function to extract data from stock market brokerage pdf file
"""
# ask user input file name
file_name = input('\n Please, enter file name: ')
# change to data folder
folder_path = pl.Path().cwd() / 'data'
os.chdir(folder_path)
# read pdf file inside data folder
pdf = parser.from_file(file_name)
text = pdf['content']
print(text)
if __name__ == '__main__':
main()
Фактическая ошибка результата:
Please, enter file name: NotaCorretagem_60076_20181009.pdf
Traceback (most recent call last):
File "C:/dev/project/Python/broker/script/data_extraction.py", line 49, in <module>
main()
File "C:/dev/project/Python/broker/script/data_extraction.py", line 28, in main
extract_pdf()
File "C:/dev/project/Python/broker/script/data_extraction.py", line 40, in extract_pdf
os.chdir(folder_path)
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\dev\\project\\Python\\broker\\script\\data'
Process finished with exit code 1
Любая помощь, пожалуйста?