I am trying to read a csv file using pyscript. There is an error message kept showing.
JsException(PythonError: Traceback (most recent call last): File "/lib/python3.10/site-packages/_pyodide/_base.py", line 429, in eval_code .run(globals, locals) File "/lib/python3.10/site-packages/_pyodide/_base.py", line 300, in run coroutine = eval(self.code, globals, locals) File "", line 1, in File "/lib/python3.10/site-packages/pandas/util/_decorators.py", line 311, in wrapper return func(*args, **kwargs) File "/lib/python3.10/site-packages/pandas/io/parsers/readers.py", line 680, in read_csv return _read(filepath_or_buffer, kwds) File "/lib/python3.10/site-packages/pandas/io/parsers/readers.py", line 575, in _read parser = TextFileReader(filepath_or_buffer, **kwds) File "/lib/python3.10/site-packages/pandas/io/parsers/readers.py", line 933, in __init__ self._engine = self._make_engine(f, self.engine) File "/lib/python3.10/site-packages/pandas/io/parsers/readers.py", line 1217, in _make_engine self.handles = get_handle( # type: ignore[call-overload] File "/lib/python3.10/site-packages/pandas/io/common.py", line 789, in get_handle handle = open( FileNotFoundError: [Errno 44] No such file or directory: 'salaries.csv' )
- I have literally put the csv file in the same folder as my html file.
- I also use the os library to print the url of the csv file but still having error.
- pwd not working as well. Tried adding path to py-env, still not working.
the code for reading csv, pandas is imported.
<py-script>
df = pd.read_csv("salaries.csv")
</py-script>`
<py-env>
- matplotlib
- numpy
- seaborn
- pandas
</py-env>
<py-script>
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import os
</py-script>
I expect someone could help me solve this issue.