I have a large dataset, which consists of both floats, ints, and strings in cells. My original data set is csv format. when converting to xlsx, I get numbers stored as text error.
I have seen this which gives script if you are manually writing to cells.
as well as this which shows how to convert csv to text.
This is my splicing of the two scripts:
import csv
import os
import glob
import xlsxwriter
from xlsxwriter import Workbook
workbook = xlsxwriter.Workbook('file.xlsx', {'strings_to_numbers': True})
for csvfile in glob.glob(os.path.join('.', '*.csv')):
workbook = Workbook(csvfile[:-4] + '.xlsx')
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)
workbook.close()
Which doesn't work for resolving the numbers stored as text issue. That issue persists.
I want to write numbers as numbers as it is converting the csv to xlsx