Error loading CSV file Pandas Python 3

0

To load a file using Pandas column 14 when adding it generates me an error, I believe because it has very long elements.

The charge of the following way:

    df4 = pd.read_csv('MAPI.csv', header=0, sep=';',usecols=[1,3,9,14,19],parse_dates = ['FOUND ON DATE '],dayfirst = True)

The error I have is the following:

    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd1 in position 18: invalid continuation byte

I attach a part of the file:

link

    
asked by Jorge Ponti 27.07.2017 в 17:06
source

2 answers

0

UnicodeDecodeError: 'utf-8' codec can not decode byte 0xd1 in position 18: invalid continuation byte

Your file contains invalid characters for the utf-8 character set, try using another one, it works for me, latin-1, you must put 'latin1'

    
answered by 12.12.2017 в 03:37
0

It must be placed with the encoding option like this:

df4 = pd.read_csv ('MAPI.csv', header = 0, sep = ';', encoding = 'latin-1', usecols = [1,3,9,14,19], parse_dates = [ 'FOUND ON DATE'], dayfirst = True)

    
answered by 27.10.2018 в 06:00