I want to convert an xlsx file to TAB delimited csv using python. After reading I was pointed to library called openpyxl (code below)
def importXLSX(fileName):
temp = os.path.basename(fileName).split('.xlsx')
tempFileName = os.path.dirname(os.path.abspath(fileName))+"/TEMP_"+temp[0]+".csv"
tempFile = open(tempFileName,'w')
wb = load_workbook(filename=fileName)
ws = wb.worksheets[0] #Get first worksheet
for row in ws.rows: #Iterate over rows
for cell in row:
cellValue = ""
if cell.value is not None:
cellValue = cell.value
tempFile.write(cellValue+'\t')
tempFile.write('\n')
os.remove(fileName)
return tempFileName
The input file I have contains billing data, but this function is converting $2,000 to 2000 and 0.00 to 0
Any idea why?