This is my first posting on Stackoverflow, but here goes nothing. I am trying to check two values in two different columns and based on those two values, I set a value in another column. Ex:
| Column A | Column X | Column Y |
|---|---|---|
| 123 | abc | |
| 124 | xyz | |
| 125 | xyz | |
| 126 | abc |
Based on Columns A and X, Y will have a value. This value is already predetermined. This is my code so far:
from openpyxl import load_workbook wb = load_workbook('filename.xlsx') ws = wb.active for cell in ws['A']: if cell.value == "123": for cell in ws['X']: if cell.value == "abc": print('AGA,TGA') #print this in column Y and the repeat the code block for all possiblites I know it doesn't work, but I want to know if there is solution for this?
https://stackoverflow.com/questions/66927137/check-two-cells-in-excel-and-setting-a-value-with-python April 03, 2021 at 10:04AM
没有评论:
发表评论