xlrd opens files in xls format?

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 that I'm using xlrd, I was wondering if xlrd is capable of reading xls files as well, which is an older Excel user format, could someone help me with that?

Author: Matheus Grossi, 2017-12-17

1 answers

Good Morning, all right?

As it says in the presentation of this page below, it is possible yes. I believe it has no difference at least from the basic part between .XLS e .xlsx with xlrd

XLRD Download

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 sheet:

insert the description of the image here

I have the following output, containing the type of the value.

insert the description of the image here

For more information some links.

Reading XLS files with python

Page from Library on Github

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

Hug.

 2
Author: Claudio Gonçalves Filho, 2017-12-18 13:33:39