I have the code below, so it opens a spreadsheet in XLS
and shows me the header. however I would like the left and right spaces to be removed and the internal spaces to be replaced by underline
is there any function in xlrd
that does this?
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 Output;
[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 is unconfigured, there are several spaces in the "pH".