Reading an excel file using Python Last Updated : 05 Jul, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report One can retrieve information from a spreadsheet. Reading, writing, or modifying the data can be done in Python can be done in using different methods. Also, the user might have to go through various sheets and retrieve data based on some criteria or modify some rows and columns and do a lot of work. Here, we will see the different methods to read our excel file.Required Modulepip install xlrdInput File: Method 1: Reading an excel file using Python using PandasIn this method, We will first import the Pandas module then we will use Pandas to read our excel file. You can read more operations using the excel file using Pandas in this article. Click here Python # import pandas lib as pd import pandas as pd # read by default 1st sheet of an excel file dataframe1 = pd.read_excel('book2.xlsx') print(dataframe1) Output: Method 2: Reading an excel file using Python using openpyxlThe load_workbook() function opens the Books.xlsx file for reading. This file is passed as an argument to this function. The object of the dataframe.active has been created in the script to read the values of the max_row and the max_column properties. These values are used in the loops to read the content of the Books2.xlsx file. You can read other operations using openpyxl in this article. Python import openpyxl # Define variable to load the dataframe dataframe = openpyxl.load_workbook("Book2.xlsx") # Define variable to read sheet dataframe1 = dataframe.active # Iterate the loop to read the cell values for row in range(0, dataframe1.max_row): for col in dataframe1.iter_cols(1, dataframe1.max_column): print(col[row].value) Output: Method 3: Reading an excel file using Python using XlwingsXlwings can be used to insert data in an Excel file similarly as it reads from an Excel file. Data can be provided as a list or a single input to a certain cell or a selection of cells. You can read other operations using Xlwings in this article. Python # Python3 code to select # data from excel import xlwings as xw # Specifying a sheet ws = xw.Book("Book2.xlsx").sheets['Sheet1'] # Selecting data from # a single cell v1 = ws.range("A1:A7").value print("Result:", v1) Output:Result: ['Name Age Stream Percentage', '0 Ankit 18 Math 95', '1 Rahul 19 Science 90', '2 Shaurya 20 Commerce 85', '3 Aishwarya 18 Math 80', '4 Priyanka 19 Science 75', None]RECOMMENDED ARTICLE - How to Automate an Excel Sheet in Python? Comment More infoAdvertise with us Next Article Reading an excel file using Python A aishwarya.27 Follow Improve Article Tags : Misc Python python-modules Practice Tags : Miscpython Similar Reads Python Tutorial - Learn Python Programming Language Python is one of the most popular programming languages. Itâs simple to use, packed with features and supported by a wide range of libraries and frameworks. Its clean syntax makes it beginner-friendly. It'sA high-level language, used in web development, data science, automation, AI and more.Known fo 10 min read Python Interview Questions and Answers Python is the most used language in top companies such as Intel, IBM, NASA, Pixar, Netflix, Facebook, JP Morgan Chase, Spotify and many more because of its simplicity and powerful libraries. To crack their Online Assessment and Interview Rounds as a Python developer, we need to master important Pyth 15+ min read SQL Commands | DDL, DQL, DML, DCL and TCL Commands SQL commands are crucial for managing databases effectively. These commands are divided into categories such as Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Data Query Language (DQL), and Transaction Control Language (TCL). In this article, we will e 7 min read Python OOPs Concepts Object Oriented Programming is a fundamental concept in Python, empowering developers to build modular, maintainable, and scalable applications. By understanding the core OOP principles (classes, objects, inheritance, encapsulation, polymorphism, and abstraction), programmers can leverage the full p 11 min read TCP/IP Model The TCP/IP model is a framework that is used to model the communication in a network. It is mainly a collection of network protocols and organization of these protocols in different layers for modeling the network.It has four layers, Application, Transport, Network/Internet and Network Access.While 7 min read Python Projects - Beginner to Advanced Python is one of the most popular programming languages due to its simplicity, versatility, and supportive community. Whether youâre a beginner eager to learn the basics or an experienced programmer looking to challenge your skills, there are countless Python projects to help you grow.Hereâs a list 10 min read Python Exercise with Practice Questions and Solutions Python Exercise for Beginner: Practice makes perfect in everything, and this is especially true when learning Python. If you're a beginner, regularly practicing Python exercises will build your confidence and sharpen your skills. To help you improve, try these Python exercises with solutions to test 9 min read Python Programs Practice with Python program examples is always a good choice to scale up your logical understanding and programming skills and this article will provide you with the best sets of Python code examples.The below Python section contains a wide collection of Python programming examples. These Python co 11 min read Basics of Computer Networking A computer network is a collection of interconnected devices that share resources and information. These devices can include computers, servers, printers, and other hardware. Networks allow for the efficient exchange of data, enabling various applications such as email, file sharing, and internet br 14 min read Python Introduction Python was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation. It was designed with focus on code readability and its syntax allows us to express concepts in fewer lines of code.Key Features of PythonPythonâs simple and readable syntax makes it beginner-frien 3 min read Like