1

I'm a new user on Python and I'm having this basic doubt on how to properly read a csv file through "pd.read_csv" from pandas package.

my code is as follows:

import pandas as pd

import numpy as np

test = pd.read_csv('C:/Users/marcu/Desktop/teste.csv')

And it gives this message of error:

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    test = pd.read_csv('C:/Users/marcu/Desktop/teste.csv')
  File "C:\Users\marcu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 646, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "C:\Users\marcu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 389, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "C:\Users\marcu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 730, in __init__
    self._make_engine(self.engine)
  File "C:\Users\marcu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 923, in _make_engine
    self._engine = CParserWrapper(self.f, **self.options)
  File "C:\Users\marcu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 1390, in __init__
    self._reader = _parser.TextReader(src, **kwds)
  File "pandas\parser.pyx", line 535, in pandas.parser.TextReader.__cinit__ (pandas\parser.c:6086)
  File "pandas\parser.pyx", line 740, in pandas.parser.TextReader._get_header (pandas\parser.c:9266)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe7 in position 22: invalid continuation byte

How can I solve this?!

Thanks for your attention, Marcus.

juanpa.arrivillaga
  • 88,713
  • 10
  • 131
  • 172

0 Answers0