Pandas can not find file

0

I'm using Pandas in Python to read a CSV file that is on my computer, but an error message appears, it does not seem to find the file:

 import pandas as pd 

 reclamacoes = pd.read_csv("C:\Users\Reinaldo\Documents\Jornalismo_de_dados\Justica\reclamacoes17-1sem1.csv",sep=';')
IOErrorTraceback (most recent call last)
<ipython-input-4-685400fce544> in <module>()
----> 1 reclamacoes = pd.read_csv("C:\Users\Reinaldo\Documents\Jornalismo_de_dados\Justica\reclamacoes17-1sem1.csv",sep=';')

c:\cygwin64\home\reinaldo\code\justica\lib\site-packages\pandas\io\parsers.pyc
     

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, skip_footer, doublequote, delim_whitespace, as_recarray,   compact_ints, use_unsigned, low_memory, buffer_lines, memory_map,   float_precision)           653 skip_blank_lines = skip_blank_lines)           654       - > 655 return _read (filepath_or_buffer, kwds)           656           657 parser_f. name = name

c:\cygwin64\home\reinaldo\code\justica\lib\site-packages\pandas\io\parsers.pyc
     

in_read (filepath_or_buffer, kwds)           403           404 # Create the parser.       - > 405 parser = TextFileReader (filepath_or_buffer, ** kwds)           406           407 if chunksize or iterator:

c:\cygwin64\home\reinaldo\code\justica\lib\site-packages\pandas\io\parsers.pyc
     

in init (self, f, engine, ** kwds)           762 self.options ['has_index_names'] = kwds ['has_index_names']           763       - > 764 self._make_engine (self.engine)           765           766 def close (self):

c:\cygwin64\home\reinaldo\code\justica\lib\site-packages\pandas\io\parsers.pyc
     

in _make_engine (self, engine)           983 def _make_engine (self, engine = 'c'):           984 if engine == 'c':       - > 985 self._engine = CParserWrapper (self.f, ** self.options)           986 else:           987 if engine == 'python':

c:\cygwin64\home\reinaldo\code\justica\lib\site-packages\pandas\io\parsers.pyc
     

in init (self, src, ** kwds)          1603 kwds ['allow_leading_cols'] = self.index_col is not False          1604       - > 1605 self._reader = parsers.TextReader (src, ** kwds)          1606          1607 # XXX

pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader.__cinit__
     

(pandas_libs \ parsers.c: 4209) ()

pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source
     

(pandas_libs \ parsers.c: 8873) ()

eclamacoes�7-1sem1.csv does not existnaldo\Documents\Jornalismo_de_dados\Justica

Does anyone know what it can be?

The file can be downloaded here: link

    
asked by anonymous 27.08.2017 / 21:46

2 answers

2

I'm somewhat rusty about Python, but I'm pretty sure that \ (backslash) is used to "escape", if so, change to / , like this:

import pandas as pd 

reclamacoes = pd.read_csv("C:/Users/Reinaldo/Documents/Jornalismo_de_dados/Justica/reclamacoes/2017-1sem1.csv",sep=';')
    
27.08.2017 / 21:53
1

Try to add r at the beginning of the string:

import pandas as pd 
reclamacoes = pd.read_csv(r'C:\Users\Reinaldo\Documents\Jornalismo_de_dados\Justica\reclamacoes17-1sem1.csv',sep=';')

r means carriage return .

  

The carriage return means returning current line without   move down. The name comes from the printer's carriage, since the   monitors were rare when the name was coined. This is commonly   escaped as "r", abbreviated CR and has ASCII value 13 or 0x0D.

    
27.08.2017 / 21:58