3

I am reading a CSV file saved from an MS SQL query. When I read file using pandas, the last column has long string which is causing NaN values. I understand this could be from windows end of line returns and/or encoding issues.

I am a newbie and don't really understand if this is an encoding problem and how to change the read statement. When I use standard Python import csv and save as utf-8 I don't have any issues re-opening and working with a txt file. Also don't find anything particularly helpful from this issue

Location = r'newpositive.csv'
df = pd.read_csv(Location)
Jonathan Eunice
  • 21,653
  • 6
  • 75
  • 77
apiccolo
  • 47
  • 5
  • 6
    I'd need to see a sample from the file. – piRSquared Dec 15 '16 at 22:45
  • thanks ..here is link to file in shared google doc.https://drive.google.com/file/d/0B7DcM13NyHAoRkE4eXNZV0M5Wk0/view?usp=sharing – apiccolo Dec 16 '16 at 12:10
  • The file I was using had carriage returns within columns and eol not properly defined. – apiccolo Jan 16 '17 at 22:04
  • Does this answer your question? [Get pandas.read\_csv to read empty values as empty string instead of nan](https://stackoverflow.com/questions/10867028/get-pandas-read-csv-to-read-empty-values-as-empty-string-instead-of-nan) – dank8 Mar 03 '23 at 02:27

0 Answers0