3
I have the code below, for him to open a spreadsheet on XLS
and show me the header. however I would like the left and right spaces to be removed and the internal spaces to be replaced by underline
there is some function in the xlrd
do that?
import xlrd
def xlread(arq_xls):
xls = xlrd.open_workbook(arq_xls)
# Pega a primeira planilha do arquivo
plan = xls.sheets()[0]
# Para i de zero ao numero de linhas da planilha
for i in xrange(plan.nrows):
# Le os valores nas linhas da planilha
yield plan.row_values(0)
for linha in xlread("teste.xls"):
print linha
Example of Saida;
[u'Cod.Lab.', u'Laudo', u'Cliente', u'Fazenda', u'Talh\xe3o', u'Profundidade', u'Descri\xe7\xe3o', u' pH ', u'pH', u' pH ', u'CE', u'MO ', u'P resina', u'S-SO4', u'K (res)', u'Na', u'Ca', u'Mg', u'Al'
As you can see where it has ~ it is not figured out and in "pH" there are several spaces.
Hi William. Can post an example of the output you are getting and the output you want?
– Anthony Accioly
edited. As I want, it would all be in the same format, lowcase, without accent and spaces.
– Guilherme Lima