Hi,

I am using Spyder IDE 5.2.0 with the default settings and python version, 
3.7.9. However, I have noticed that the csv writer inserts extra new lines 
in the output file. Example is shown below:
    import pandas as pd 
    import csv df = pd.read_csv('test.csv', usecols=['ID','Name','Metric',
'Unit','Value']) 
    f1 = open('test2.csv', 'w') 
    df.to_csv(f1) 
    f1.close() 

The input is
    ID,Name,Metric,Unit,Value 
   0,K1,M1,usecond,200 
   0,K1,M2,,5 
   1,K2,M1,msecond,1 
   1,K2,M2,,10 
   2,K2,M1,msecond,500 
   2,K2,M2,,8 

But the final output looks like
,ID,Name,Metric,Unit,Value 

0,0,K1,M1,usecond,200 

1,0,K1,M2,,5 

2,1,K2,M1,msecond,1 

3,1,K2,M2,,10 

4,2,K2,M1,msecond,500 

5,2,K2,M2,,8 

<https://i.stack.imgur.com/rQ6Ut.png>



Any idea to fix that? The system information is shown below

Spyder IDE 5.2.0 | Python 3.7.9 64-bit | Qt 5.12.10 | PyQt5 5.12.3 | 
Windows 10



Regards,
Mahmood

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/spyderlib/5afd9d5b-1151-4bd9-b20c-dd2bdb4f6cc5n%40googlegroups.com.

Reply via email to