I'm using script from here convert-csv-to-xlsx to do the conversion with little modification (I add several arguments including 'strings_to_numbers': True ):
import os
import glob
import csv
from xlsxwriter.workbook import Workbook
for csvfile in glob.glob(os.path.join('.', '*.csv')):
workbook = Workbook(csvfile[:-4] + '.xlsx', {'constant_memory': True, 'strings_to_urls': False, 'strings_to_numbers': True})
worksheet = workbook.add_worksheet()
with open(csvfile, 'rt', encoding='utf8') as f:
reader = csv.reader(f)
for r, row in enumerate(reader):
for c, col in enumerate(row):
worksheet.write(r, c, col)
print(r)
workbook.close()
Everything works fine but as I've added the above mentioned argument I'm getting all the numbers as numbers in my xlsx files. I need to keep one column (first) as a string as there are long numbers which convert (due to excel number length limitation) to something like this 1,04713E+18 example
Maybe i need to remove the argument and convert the needed columns from strings to numbers at the end. Is that possible?