Use the csv
module
import csv
rows = [['Bike No.', 'Purchase Date', 'Batt %', 'Last Maintenance', 'KM since Last', 'Service?'],
['T101', '10/4/2016', '55', '10/1/2017', '25.08', 'N'],
['T102', '1/7/2016', '10', '15/5/2017', '30.94', 'N'],
['T103', '15/11/2016', '94', '13/6/2017', '83.16', 'Y'],
['T104', '25/4/2017', '58', '10/1/2017', '25.08', 'N'],
['T105', '24/5/2017', '5', '20/6/2017', '93.8', 'Y']]
with open('output.csv', 'w') as f:
writer = csv.writer(f)
writer.writerows(rows)
Output:
Bike No.,Purchase Date,Batt %,Last Maintenance,KM since Last,Service?
T101,10/4/2016,55,10/1/2017,25.08,N
T102,1/7/2016,10,15/5/2017,30.94,N
T103,15/11/2016,94,13/6/2017,83.16,Y
T104,25/4/2017,58,10/1/2017,25.08,N
T105,24/5/2017,5,20/6/2017,93.8,Y