Python Forum

Full Version: problem with opening csv file in pandas
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!
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
Thanks !