1

Opening a .csv file, all the _(underscores) are getting converted to +AF8-.

I can see that there is some kind of format issue but how to solve this.

I am getting the same error when I write a script to read a .csv file using pandas.

full_data = pd.read_csv('../data/full_data.csv', error_bad_lines=False)
print (full_data.info())

This is the output:

sdmax+AF8-posn    5530 non-null float64

sdmax_posn was read like that.

Original Image Error_Image

Thanks!

janu777
  • 1,940
  • 11
  • 26
  • I'd guess there was an invalue somewhere. Do you know if an entry in particulare caused the problem? – vmonteco Dec 02 '17 at 13:26
  • Also, could you post a sample of the csv file itself? – vmonteco Dec 02 '17 at 13:27
  • Are you sure this is a Pandas issue and not an OpenOffice issue? See this response: https://stackoverflow.com/questions/38923688/openoffice-when-exporting-csv-underscores-are-replaced-with-af8 – chthonicdaemon Dec 02 '17 at 13:38
  • As @chthonicdaemon link suggest use `encoding='utf8'` inside pd.read_csv . – Bharath M Shetty Dec 02 '17 at 14:39
  • Thank you @chthonicdaemon, encoding='utf8' solved the pandas issue. – janu777 Dec 04 '17 at 09:39
  • For me the solution was encoding='utf7', apparently encoding can change by accident when you open and save files in excel or libreoffice calc. I tried different encodings while opening the file in calc and then when I saw one that worked I input that in the encoding parameter of read_csv. – Gus Mar 10 '23 at 15:11

0 Answers0