I already get the value from text file and write it to excel file. But somehow in the excel cell the integer written in string. So there's a green triangle in the cell. Like this

I want to print like this

and this is the code
from itertools import chain
import glob ,csv, sys, os
sys.path.insert(0,'D:/apera/Python27/xlwt-0.7.5')
import xlwt
openMesureFile = 'D:/apera/Workspace/Python scripting test 2/sounding0.txt'
savePlace = 'D:/apera/Workspace/Sounding/sounding{0:03d}.txt'
openSoundingFile = 'D:/apera/Workspace/Sounding/*.txt'
with open(openMesureFile, 'rb') as inf:
header = next(inf)
for index, line in enumerate(inf,start=0):
with open(savePlace.format(index) ,'w') as outf:
outf.write('Filename:;%s\n\n' %outf.name)
outf.write(header)
for line in chain([line], inf):
if 'Sounding :;Sondage n°' in line:
header = line
break
outf.write(line)
for filename in glob.glob(openSoundingFile):
wb = xlwt.Workbook(encoding="latin1")
sheet = wb.add_sheet('INPUT')
newName = filename
spamReader = csv.reader(open(filename, 'rb'), delimiter=';',quotechar='"')
for rowx, row in enumerate(spamReader):
for colx, value in enumerate(row):
sheet.write(rowx, colx, value)
sheet.col(0).width = 5555
sheet.col(1).width = 11110
sheet.col(2).width = 5555
sheet.col(3).width = 3333
wb.save(newName[:-4] + ".xls")
print "success"
valuein the statement. That issheet.write(rowx, colx, float(value)). That has always worked for me. Do try and check.csvwon't implicitly cast the numbers tofloat; you have to do it manually -sheet.write(rowx, colx, float(value)).write()in python always takes an argument of typestr. Therefore, it will always write string in the file.file.write, it'sxlwt.Worksheet.write.