Is there any way to read an XLS file and manipulate it in Python?

2

Is there any way to read an XLS file and manipulate it in Python? Does any library allow this?

    
asked by anonymous 08.08.2016 / 02:31

1 answer

2
import xlrd

def xlread(arq_xls):
    """
    Gerador que le arquivo .xls
    """

    # Abre o arquivo
    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(i)

for linha in xlread('test.xls'):
    print (linha)

pip install xlrd

    
08.08.2016 / 02:45