Streamlit is just a waste of time

my app is woking well on local host but when i try to deploy it . it not even able to read csv file. Have been trying to solve it for a whole day.
this the error am getting

[21:12:43] ๐Ÿ Python dependencies were installed from /app/visulization_of_kenya_voters/requirements.txt using pip.
[21:12:43] ๐Ÿ“ฆ Processed dependencies!
  Stopping...

Collecting usage statistics. To deactivate, set browser.gatherUsageStats to False.




[21:12:46] ๐Ÿ”„ Updated app!
2023-11-23 21:12:47.388 Uncaught app exception
Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
    exec(code, module.__dict__)
  File "/app/visulization_of_kenya_voters/myapp.py", line 9, in <module>
    df=pd.read_csv(r"https://github.com/YonQwon/visulization_of_kenya_voters/blob/main/data/voters.csv", low_memory=False)
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 912, in read_csv
    return _read(filepath_or_buffer, kwds)
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 583, in _read
    return parser.read(nrows)
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1704, in read
    ) = self._engine.read(  # type: ignore[attr-defined]
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/parsers/c_parser_wrapper.py", line 239, in read
    data = self._reader.read(nrows)
  File "pandas/_libs/parsers.pyx", line 796, in pandas._libs.parsers.TextReader.read
  File "pandas/_libs/parsers.pyx", line 884, in pandas._libs.parsers.TextReader._read_rows
  File "pandas/_libs/parsers.pyx", line 861, in pandas._libs.parsers.TextReader._check_tokenize_status
  File "pandas/_libs/parsers.pyx", line 2029, in pandas._libs.parsers.raise_parser_error
pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 33, saw 8

2023-11-23 21:12:47.553 Uncaught app exception
Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
    exec(code, module.__dict__)
  File "/app/visulization_of_kenya_voters/myapp.py", line 9, in <module>
    df=pd.read_csv(r"https://github.com/YonQwon/visulization_of_kenya_voters/blob/main/data/voters.csv", low_memory=False)
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 912, in read_csv
    return _read(filepath_or_buffer, kwds)
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 583, in _read
    return parser.read(nrows)
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1704, in read
    ) = self._engine.read(  # type: ignore[attr-defined]
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/parsers/c_parser_wrapper.py", line 239, in read
    data = self._reader.read(nrows)
  File "pandas/_libs/parsers.pyx", line 796, in pandas._libs.parsers.TextReader.read
  File "pandas/_libs/parsers.pyx", line 884, in pandas._libs.parsers.TextReader._read_rows
  File "pandas/_libs/parsers.pyx", line 861, in pandas._libs.parsers.TextReader._check_tokenize_status
  File "pandas/_libs/parsers.pyx", line 2029, in pandas._libs.parsers.raise_parser_error
pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 33, saw 8

Rafiki - Please check out the guidelines on how to post an effective question here and update your post to help the community answer your question.

2 Likes

This the link to the code ([GitHub - YonQwon/visulization_of_kenya_voters]
and here is the trace back error

That code cannot work in any hosting, local or remote, because the url doesnโ€™t point to a csv file. It is not streamlitโ€™s fault that you donโ€™t know how to get your data.

You can just read the file from the host file system.

df = pd.read_csv("data/voters.csv")
1 Like

Hi @samy_migwi

I understand the frustration when debugging the app, however as @Goyo had pointed out the error lies in the file loading line in the code.

On Line 9, it seems that youโ€™d like to read your CSV from your GitHub repo:

df=pd.read_csv("https://github.com/YonQwon/visulization_of_kenya_voters/blob/main/data/voters.csv")

The above URL (https://github.com/YonQwon/visulization_of_kenya_voters/blob/main/data/voters.csv) used as the input argument to your pd.read_csv() method is not in a format that would be compatible with pd.read_csv().

Instead, please use https://raw.githubusercontent.com/YonQwon/visulization_of_kenya_voters/main/data/voters.csv instead such that it becomes:

df=pd.read_csv("https://raw.githubusercontent.com/YonQwon/visulization_of_kenya_voters/main/data/voters.csv")

Hope this helps!

Thank you so much for the support. I like the streamlite community. Thank you sir.

1 Like

Glad to hear that it worked out @samy_migwi

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.