I'm using csv(txt) file to make graphs, but Django doesn't want to find it. So I can't understand, where should I create a file.
def get_plot():
df = pd.read_csv('jobibi.txt', sep=',', encoding='utf-8')
And the output on the web page:
FileNotFoundError at /analytics/
[Errno 2] No such file or directory: 'jobibi.txt'
You need to provide the full path to the file you want to open.
It is generally considered to be a bad idea to hardcode the path of the file in the function call.
You can import the path of your project from your settings.py and go from there.
You can navigate this path like this:
For more detailed information on how to navigate the paths in python - pathlib docs
It should look something like this. Now you should be able to read your file.
If your files are always in the same directory i recommend adding a dedicated variable in your settings.py
Then you only need to import MY_CSV_PATH and add the filename to it.
I hope this helped. Let me know if you are still having problems with it.