5
respostas

leitura do arquivo csv

Prezados, ao tentar ler o arquivo csv, ressalto que o arquivo é grande 27.703 KB retorna este erro:

File "pandas\_libs\parsers.pyx", line 2132, in pandas._libs.parsers.raise_parser_error

ParserError: Error tokenizing data. C error: Expected 1 fields in line 786, saw 4
5 respostas

Oi Jefferson. O erro apareceu porque o pandas esperava um certo número de elementos em uma linha e recebeu mais elementos.

Esse tipo de erro normalmente aparece porque o pandas está lendo o arquivo esperando um separador como a vírgula, mas o texto do arquivo está separado com um tab, por exemplo. Pode ser outro separador no seu caso.

Para testar o separador tab você pode usar o comando:

data=pd.read_csv("nome_do_arquivo", sep='\t') 

base=pd.read_csv('fale.csv', sep ='\t') base=pd.read_csv('fale.csv', sep ='\t', na_filter=False, header= None, encoding = "ISO-8859-1", error_bad_lines= False)

fiz essas duas tentativas e na ultima retornou esse erro abaixo:

2\nSkipping line 226411: expected 1 fields, saw 2\nSkipping line 226412: expected 1 fields, saw 2\nSkipping line 226750: expected 1 fields, saw 3\nSkipping line 226751: expected 1 fields, saw 3\nSkipping line 226753: expected 1 fields, saw 3\nSkipping line 226754: expected 1 fields, saw 3\nSkipping line 227149: expected 1 fields, saw 2\nSkipping line 228787: expected 1 fields, saw 6\nSkipping line 229878: expected 1 fields, saw 4\nSkipping line 229879: expected 1 fields, saw 4\nSkipping line 229880: expected 1 fields, saw 4\nSkipping line 229881: expected 1 fields, saw 4\nSkipping line 229882: expected 1 fields, saw 4\nSkipping line 229883: expected 1 fields, saw 4\nSkipping line 229884: expected 1 fields, saw 4\nSkipping line 229885: expected 1 fields, saw 4\nSkipping line 229886: expected 1 fields, saw 4\nSkipping line 229887: expected 1 fields, saw 4\nSkipping line 229888: expected 1 fields, saw 4\nSkipping line 229889: expected 1 fields, saw 4\nSkipping line 229890: expected 1 fields, saw 4\nSkipping line 229891: expected 1 fields, saw 4\nSkipping line 230051: expected 1 fields, saw 6\nSkipping line 230052: expected 1 fields, saw 6\nSkipping line 230160: expected 1 fields, saw 2\nSkipping line 230161: expected 1 fields, saw 2\nSkipping line 230162: expected 1 fields, saw 2\nSkipping line 230163: expected 1 fields, saw 2\nSkipping line 230793: expected 1 fields, saw 2\nSkipping line 231494: expected 1 fields, saw 2\nSkipping line 232328: expected 1 fields, saw 5\nSkipping line 233587: expected 1 fields, saw 2\nSkipping line 233588: expected 1 fields, saw 2\nSkipping line 233589: expected 1 fields, saw 2\nSkipping line 233590: expected 1 fields, saw 2\nSkipping line 233591: expected 1 fields, saw 2\nSkipping line 233592: expected 1 fields, saw 2\nSkipping line 233593: expected 1 fields, saw 2\nSkipping line 233594: expected 1 fields, saw 2\nSkipping line 233595: expected 1 fields, saw 2\nSkipping line 233620: expected 1 fields, saw 2\nSkipping line 233621: expected 1 fields, saw 2\n

Jefferson, pode disponibilizar o arquivo (csv)? Mesmo que com apenas algumas linhas?

Sim, como envio?

Compartilha um arquivo público no Google Drive, OneDrive ou Dropbox. Algo assim.