Doing stuff in python is a bliss in itself, it is such a beautiful language which provides us one of the most easiest syntax among any of the programming languages. Being a scripting language, python is used almost everywhere especially when it comes to working with data, manipulating data.

Most of the times when it comes to data, we mostly speaking in reference with Excel spreadsheets. Reading, writing and manipulating data from excel spreadsheets can be easily done using python. There are many third-party packages available to work with spreadsheets using Python. One of the package is xlrd. This package can be used in Linux or Mac or Window, best works with Linux. This package does not come installed with python, we have to install it using:-
pip install xlrd
One can also download the xlrd from here.
Reading an excel
Python script can be easily written to read an excel. It could be anything,
- Rows
- Columns
- Cell value
import xlrd loc = ("path of file") wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) # For row 0 and column 0 sheet.cell_value(0, 0) # Extracting number of columns print(sheet.ncols)# Program extracting all columnsfor i in range(sheet.ncols):print(sheet.cell_value(0, i))print(sheet.row_values(1)) |
The above is written in a way that the code is self-explanatory and you can easily make of what each syntax is doing. With this one can easily read data from excel.
Which module is used for writing and manipulating spreadsheets in python??? Comment down below.