Skip to content

Instantly share code, notes, and snippets.

@smaroukis
Last active September 26, 2017 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smaroukis/160d582bb3f9efcb2ca6c90780d4f7a4 to your computer and use it in GitHub Desktop.
Save smaroukis/160d582bb3f9efcb2ca6c90780d4f7a4 to your computer and use it in GitHub Desktop.
def col_to_int(col):
"""Converts excel COL to INT (zero indexed)"""
if len(col) == 1:
return ord(col.upper()) - ord('A')
if len(col) == 2:
n_alphabet = 26
return (col_to_int(col[0])+1)*n_alphabet+col_to_int(col[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment