Created
May 18, 2020 07:10
-
-
Save mithunkamat/11f62771198e96d8a5d13dd577c4f558 to your computer and use it in GitHub Desktop.
Searching a column with openpyxl.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# define function to search a given column in an openpyxl worksheet object | |
def search_col(sheet, column, value, limit=100): | |
# loop through each row upto the limit, beginning from 1 | |
for row in range(1, limit+1): | |
if sheet[f"column{row}"].value == value: | |
# if we find the value we are searching for, return col + row | |
return (col, row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment