I'm getting error when i make postman request to my api when trying to read files from a directory.
cwd = os.getcwd()
print(cwd)
cwd = cwd.replace('\\','/')
print(cwd)
path = cwd + "/training_data/"
print(path)
try:
for files in os.listdir(path):
data = open(path + files,'r').readlines()
bot.train(data)
except Exception as e:
return jsonify("Error while opening file",path,cwd,os.listdir(path))
I'm getting the following exception:
[
"Error while opening file",
"C:/Users/RakeshS/Desktop/app/training_data/",
"C:/Users/RakeshS/Desktop/app",
[
"code.txt",
"deputation1.txt",
"football.txt",
"Greeting.txt",
"internetaccess.txt",
"intravels.txt",
"sentiment.txt",
"system.txt"
]]
Why is it not able to open the file and read data when i'm getting all the list of files inside the directory?