Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
2. Loading files
Summary

Instruction

To start using openpyxl, we have to install it and load it into our application:

import openpyxl

If you only want to load and read files, there is no need to import the whole openpyxl module. We just need one function, load_workbook():

from openpyxl import load_workbook

This way, instead of importing the whole module, we indicate that we only want to import one particular function. The load_workbook function accepts the path to a given file as its argument and loads the file.

wb = load_workbook("food.xlsx")

We recommend assigning the result of the load_workbook function to the wb (workbook) variable.

Exercise

Import the load_workbook function and load the january_diet.xlsx file. Assign the workbook to the wb variable.