Read Data in Excel Files using Python

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.

Python Library to Read Excel Files

To read data from the workbooks, 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

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 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, in order 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 Particular Worksheet in Excel in Python

You can also read a particular worksheet in the Excel file by following the steps below.

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

Get a Free API License

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

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 worksheet or all the worksheets in an Excel workbook. 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.

See Also