Pandas.read_csv "unexpected end of data" Error

For me adding this fixed it:

error_bad_lines=False

It just skips the last line. So instead of

reviews = pd.read_csv('br.csv', engine='python', encoding='utf-8')

reviews = pd.read_csv('br.csv', engine='python', encoding='utf-8', error_bad_lines=False)


In my case, I don't want to skip lines, since my task is required to count the number of data records in the csv file. The solution that works for me is using the Quote_None from csv library. I try this from reading on some websites that I did not remember, but it works.

To describe my case, previouly I have the error: EOF .... Then I tried using the parameter engine='python'. But that introduce another bug for next step of using the dataframe. Then I try quoting=csv.Quote_None, and it's ok now. I hope this helps

import csv    
read_file = read_csv(full_path, delimiter='~', encoding='utf-16 BE', header=0, quoting=csv.QUOTE_NONE)

Tags:

Python

Pandas