Home > Back-end >  Heroku: FileNotFoundError [Errno 2] during file IO operations on deployment - Python
Heroku: FileNotFoundError [Errno 2] during file IO operations on deployment - Python

Time:10-22

I have successfully deployed a webapp to Heroku. However, my file IO operations are not happening because Heroku is unable to recognize the files in the folders.

My folder structure is:

- Project Folder
  - datafolder
    - otherdata.csv
  - main.py
  - userdata.csv

When I use df = pd.read_csv('userdata.csv') all works fine, because this is in the root directory as the main file and Heroku is able to find it, and allow read write operations.

However when I use df = pd.read_csv('datafolder\\otherdata.csv') Heroku logs display this error:

FileNotFoundError: [Errno 2] No such file or directory: 'datafolder\\otherdata.csv'

When I ran bash command using Heroku CLI, I can see the datafolder as well as csv file. Why is Heroku not able to recognise "datafolder" and the csv inside it?

CodePudding user response:

You are not using the path in correct way, you just have to use df = pd.read_csv('datafolder/otherdata.csv') and it should be working fine.

  • Related