Python Forum
problem with opening csv file in pandas - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: problem with opening csv file in pandas (/thread-28369.html)



problem with opening csv file in pandas - saratha - Jul-16-2020

Hello everyone,
See, I'm a Pycharm user and I'm currently learning how to use pandas for data analysis. But the problem is that I cannot open my csv file. Here is how it goes:

Code:
import pandas as pd
data = pd.read_csv('This PC\\Downloads\\sample.csv')
print(data)
Error:
Error:
Traceback (most recent call last): File "C:/Users/91960/PycharmProjects/mmm/python.py", line 2, in <module> data = pd.read_csv('This PC\\Downloads\\sample.csv','r') File "C:\Users\91960\PycharmProjects\mmm\venv\lib\site-packages\pandas\io\parsers.py", line 676, in parser_f return _read(filepath_or_buffer, kwds) File "C:\Users\91960\PycharmProjects\mmm\venv\lib\site-packages\pandas\io\parsers.py", line 448, in _read parser = TextFileReader(fp_or_buf, **kwds) File "C:\Users\91960\PycharmProjects\mmm\venv\lib\site-packages\pandas\io\parsers.py", line 880, in __init__ self._make_engine(self.engine) File "C:\Users\91960\PycharmProjects\mmm\venv\lib\site-packages\pandas\io\parsers.py", line 1114, in _make_engine self._engine = CParserWrapper(self.f, **self.options) File "C:\Users\91960\PycharmProjects\mmm\venv\lib\site-packages\pandas\io\parsers.py", line 1891, in __init__ self._reader = parsers.TextReader(src, **kwds) File "pandas\_libs\parsers.pyx", line 374, in pandas._libs.parsers.TextReader.__cinit__ File "pandas\_libs\parsers.pyx", line 674, in pandas._libs.parsers.TextReader._setup_parser_source FileNotFoundError: [Errno 2] File This PC\Downloads\sample.csv does not exist: 'This PC\\Downloads\\sample.csv'
Please help!


RE: problem with opening csv file in pandas - Larz60+ - Jul-16-2020

the error message is pretty clear.
'This PC\\Downloads\\sample.csv' does not exist
looks like 'This PC' needs to be replaced with a real directory name


RE: problem with opening csv file in pandas - saratha - Jul-21-2020

Thanks !