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