I'm coming from the xls to csv converter . It helps me to converting excel sheets to csv files.
I've integer values in my excel-sheets, while I'm writing them into csv files, they got converted into float values. example.
1 > 1.0
My data is something like,
no name marks friend
01 kirk 190 sandy
02 stark 100 kim
all the above integer becomes float.
no name marks friend
01.0 kirk 190.0 sandy
02.0 stark 100.0 kim
Is there any solution to override the issue?
code for reference,
# -*- coding: utf-8 -*-
import xlrd
import csv
from os import sys
def csv_from_excel(excel_file):
workbook = xlrd.open_workbook(excel_file)
all_worksheets = workbook.sheet_names()
for worksheet_name in all_worksheets:
worksheet = workbook.sheet_by_name(worksheet_name)
your_csv_file = open(''.join([worksheet_name,'.csv']), 'wb')
wr = csv.writer(your_csv_file, quoting=csv.QUOTE_ALL)
for rownum in xrange(worksheet.nrows):
wr.writerow([unicode(entry).encode("utf-8") for entry in worksheet.row_values(rownum)])
your_csv_file.close()
if __name__ == "__main__":
csv_from_excel(sys.argv[1])