I have a list of lists below:
mylist = [['HBASE-5727', 2, '66772ce043', '1044d5e353'],
['HBASE-5286', 2, '180b41f518', '0132176084'],
['HBASE-532', 3, 'ef5bb6f316', 'fb2db8cdaa']
]
I need to save that list into CSV file. I wrote this code:
with open("numberofbugs.csv",'w') as csvfile:
header = ['bug_id', 'number_of_bugs', 'first_commitID', 'last_commitID']
writers = csv.writer(csvfile)
writers.writerow(header)
for item in mylist:
writers.writerow(item)
However, the fourth element in the second sublist is written as integer 132176084
. Here's the CSV file resulted:
bug_id | number_of_bugs | first_commitID | last_commitID |
--------------------------------------------------------------
HBASE-5727 | 2 | 66772ce043 | 1044d5e353 |
HBASE-5286 | 2 | 180b41f518 | 132176084 |
HBASE-532 | 3 | ef5bb6f316 | fb2db8cdaa |
Why is it happen and how to keep the type of the element as it is written in the list (as string
), so the value still 0132176084
instead of 132176084
?