0

I am reading a csv file and performing some operation on the data and write data back to csv file While reading the data the "N/A" values converted as NaN

data in my csv file is:

enter image description here

My Pandas code is:

for df in pd.read_csv(filename, dtype='str', sep='|'):   
    print(df)
    df.to_csv(filetar, sep='|', index=False, encoding='utf-8')

df data is as below:

enter image description here

while writing the data using to a file using to_csv the Value "NaN" didn't write either N/A.

enter image description here

Basically N/A converted NaN further Blank while writing CSV File.

I write write the data as N/A just like the source file. Any help on this.

Roshan
  • 377
  • 3
  • 20

0 Answers0