Spreadsheet Encoding

In this lesson, you will learn how to convert the column IDs in a spreadsheet into an integer in Python.

We'll cover the following

In this lesson, we will be considering how to solve the problem of implementing a function that converts a spreadsheet column ID (i.e., “A”, “B”, “C”, …, “Z”, “AA”, etc.) to the corresponding integer. For example, “A” equals 1 because it represents the first column, while “AA” equals 27 because it represents the 27th column.

We will cover how to solve this problem algorithmically, and then code a solution to this question in Python.

The key insight is to think of the column IDs as base 26 integers.

In the illustration below, you can see how we represent “314” as a base 10 number.

Get hands-on with 1200+ tech skills courses.