Read data in Excel files using Python

MS Excel provides a convenient way of keeping and sharing data in the form of rows and columns. More often, Excel files are used to store huge datasets having hundreds and thousands of records. While working with Excel files in Python, you may need to read data from each cell in the worksheets. To achieve that, this article shows how to read an Excel file in Python. You will learn how to read data from a single worksheet or all the worksheets in an Excel workbook.

Reading an Excel File in Python - Library Installation

To read data from the Excel sheets, we will use Aspose.Cells for Python via Java. It is a powerful and feature-rich Python library to create MS Excel files. Moreover, it allows you to read and manipulate existing Excel files seamlessly. You can download the library or install it using the following pip command.

pip install aspose-cells

How to Read an Excel File in Python

Before we start reading the data, let’s have an overview of how the data is managed in an Excel file. An Excel file is termed as a workbook that acts as a container. Each workbook contains one or more worksheets and every worksheet is composed of a number of cells. These cells are uniquely identified by the rows and columns. So, to read data from a cell, you need to know its row and column index.

The following are the steps to read an Excel file and print its data in Python.

The following code sample shows how to read an Excel file in Python.

The following is the output we get after running the code sample above.

Reading data in the worksheets of Excel file in Python

Reading an Excel File in Python

Read a Specific Excel Sheet in Python

You can also read a particular Excel sheet in Python by following the steps below.

The following code sample shows how to read data from a particular Excel sheet in Python.

Python Excel File Reader - Get a Free License

You can use Aspose.Cells for Python via Java without evaluation limitations by requesting a free temporary license.

Python Library to Read Excel Files - Explore More

You can explore more about the Python spreadsheet library using the documentation. In case you would have any questions or queries, feel free to let us know via our forum.

Conclusion

In this article, you have learned how to read Excel files in Python. Moreover, you have seen how to read data from a particular sheet or all the sheets in an Excel workbook.

See Also