How to Update Excel Files Using Python

Gustavo Santos
gustavorsantos
Published in
5 min readSep 10, 2021

--

Learn the basics of openpyxl package and create scripts to improve your daily job.

Photo by Mika Baumeister on Unsplash

Introduction

openpyxl is a Python library to allow you to read and write Excel files using an easy code, thus enabling people to improve work performance.

When I say improve performance, allow me to explain why: I have 13+ years in the IT industry and I may say that many of those were spent behind many Excel sheets and workbooks, as well as writing long VBA codes to automate some tasks.

With openpyxl library we can use Python to process all the data (like manipulation, explorations) if we have too much data, as well as we can create scripts that will play the same role as the VBA macros, but easier to write and maintain.

Openpyxl Basics

To install and import, same old, same old… pip install openpyxl if you still don’t have it. Anaconda already brings it, so if you’re using it, just go to import.

from openpyxl import Workbook, load_workbook# If you need to get the column letter, also import this
from openpyxl.utils import get_column_letter

Access Files , Sheets and Cells

--

--

Gustavo Santos
gustavorsantos

Data Scientist. I extract insights from data to help people and companies to make better and data driven decisions. | In: https://www.linkedin.com/in/gurezende/