Error in reading csv file in pandas



(I tend to reach either one of - Neeraj Sarwan sir, kunal jain sir, or sunil ray sir )

Hello sir,
I am prerit , i am enrolled in the course basic python for data science and the datahack , in the students fest 2018.

i have reached python for data science section whose instructor is Neeraj Sarwan sir . i tried to impement the things tought in the module 'reading a csv file -implementation ’

i have installed both jupyter notebook and pandas . the problem i am frequently facing while trying to read the csv file . I converted an excel file to a csv file and the renamed it from decision tree to
data .csv . but while trying to read data.csv file i have in the jupyter (local host 8888)

pandas is imported quiet well , but in the next step when i try to read data.csv file , it throws a large instruction and in the end its just that data.csv file doesn’t exist . please help

the error is

"FileNotFoundError Traceback (most recent call last)
in ()
----> 1 dataFrame = pd.read_csv(“data.csv”)

c:\users\abc\appdata\local\programs\python\python35-32\lib\site-packages\pandas\io\ in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, doublequote, delim_whitespace, low_memory, memory_map, float_precision)
** 676 skip_blank_lines=skip_blank_lines)**
** 677 **
–> 678 return _read(filepath_or_buffer, kwds)
** 679 **
** 680 = name**

c:\users\abc\appdata\local\programs\python\python35-32\lib\site-packages\pandas\io\ in _read(filepath_or_buffer, kwds)
** 438 **
** 439 # Create the parser.**
–> 440 parser = TextFileReader(filepath_or_buffer, kwds)
** 441 **
** 442 if chunksize or iterator:

c:\users\abc\appdata\local\programs\python\python35-32\lib\site-packages\pandas\io\ in init(self, f, engine, kwds)
** 785 self.options[‘has_index_names’] = kwds[‘has_index_names’]

** 786 **
–> 787 self._make_engine(self.engine)
** 788 **
** 789 def close(self):**

c:\users\abc\appdata\local\programs\python\python35-32\lib\site-packages\pandas\io\ in _make_engine(self, engine)
** 1012 def _make_engine(self, engine=‘c’):**
** 1013 if engine == ‘c’:**
-> 1014 self._engine = CParserWrapper(self.f, self.options)
** 1015 else:

** 1016 if engine == ‘python’:**

c:\users\abc\appdata\local\programs\python\python35-32\lib\site-packages\pandas\io\ in init(self, src, kwds)
** 1706 kwds[‘usecols’] = self.usecols

** 1707 **
-> 1708 self._reader = parsers.TextReader(src, kwds)
** 1709 **
** 1710 passed_names = self.names is None

pandas_libs\parsers.pyx in pandas._libs.parsers.TextReader.cinit()

pandas_libs\parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()

FileNotFoundError: File b’data.csv’ does not exist"



Can you please share the code line and a screenshot of the error? Also, please check that the path you have used to read the file is correct.

For example, if i have a csv file saved on my desktop, I will use the following code to read my csv file: df=pd.read_csv("/home/aishwarya/data.csv") . In case you have not changed the location of your file, your file will be saved in downloads, hence you have to write the path accordingly.

If you want to directly access the file as df=pd.read_csv("data.csv") you must save the file in home location on your system


yeah ,thanx for the reply quick as lightning. i will sure try again and write the file location .
thank you…

but home location???
desktop is it, you are trying to say??


tried changing the location, but still it shows an error:

File “”, line 1
** dataFrame = pd.read_csv(“C:\Users\abc\Desktop\data.csv”)**
** ^**
SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape



If the file is in home, you can directly access it. I have given an example of the file present on my desktop.


Did you save your file on the desktop?

Also please use / instead of \


it is present on the desktop , but i cant access it,

this has turned into a real mess


thank you so so much…it finally worked …i ma really happy now…thanx

:smile: :wink:


Glad it worked.