This article introduces how to install
xlrd in Python.
xlrd in Python
Sometimes while working in Python, we need to work with spreadsheets. Python has many solutions for working in spreadsheets, and the
xlrd module is one of them.
xlrd module, we can retrieve information, read, write and modify spreadsheet data. We can also go through various sheets and retrieve data from multiple spreadsheets.
As shown below, we can easily install the
xlrd module using
pip install xlrd
If you have
pip with a version lower than 3, this command will not work. Use the command below instead.
pip3 install xlrd
We will go through an example in which we will access a spreadsheet and get its content using
So let’s create a new spreadsheet with columns such as the name, email, and roll number and add some data as shown below.
Now, let’s try to get data from the spreadsheet.
# Location of the ile
location = "spreadsheet.xls"
# To open Sheet
workB = xlrd.open_workbook(location)
worksheet = workB.sheet_by_index(0)
# For row 0 and column 0
When we run the above code, the output will be:
So, in this way, we can easily install the
xlrd module and use it to work with spreadsheets. The
xlrd module has many functions to perform different tasks related to spreadsheets with the help of these functions.