xlrd open files in xls format?

0

I'm sorry for my ignorance on the subject, but I'm developing a Python script that reads Excel files to get certain information in those, and for this I'm using xlrd, I wanted to know if xlrd is able to read xls files too, which is an older Excel user format, could anyone help me with this?

    
asked by anonymous 17.12.2017 / 18:44

1 answer

1

Good morning, all right?

As you say in the presentation on this page, it is possible to do so. I believe there is no difference at least in the basic part between .xls and .xlsx with xlrd

XLRD Download

It would look like this:

import xlrd #importando a biblioteca

workbook = xlrd.open_workbook('teste.xls') # Escolhe o arquivo a ser lido.

worksheet = workbook.sheet_by_index(0) #Escolha a aba a ser lida. 

for i in range(worksheet.nrows): #itere sobre os itens da aba 
    print(worksheet.row(i))

In my case, with this input worksheet:

Ihavethefollowingoutput,containingthevaluetype.

Formoreinformationsomelinks.

Reading xls files with python

Github library page

Reading data from a spreadsheet and sending an XLRD + SMTPLIB warning email

Thank you.

    
18.12.2017 / 14:33