This commit is contained in:
alex 2024-08-04 12:24:44 -04:00
parent f43261e718
commit 4f33de071c
1 changed files with 11 additions and 7 deletions

View File

@ -1,22 +1,26 @@
SOURCE_ID_FIELD = "Customer ID" SOURCE_ID_FIELD = "Customer ID"
SOURCE_ID_COL = "H"
TARGET_ID_FIELD = "Square Customer ID" TARGET_ID_FIELD = "Square Customer ID"
TARGET_ID_COL = "D"
SOURCE_EMAIL_FIELD = "Customer Email" SOURCE_EMAIL_FIELD = "Customer Email"
TARGET_EMAIL_FIELD = "Email Address" TARGET_EMAIL_FIELD = "Email Address"
SOURCE_GYMNAST_FIELD = "Gymnast" SOURCE_GYMNAST_FIELD = "Gymnast"
SOURCE_GYMNAST_COL = "F"
TARGET_TEAM_FIELD = "Team" TARGET_TEAM_FIELD = "Team"
FILE_NAME = "PFAC Order Report.copy.xlsx" FILE_NAME = "transactions-2022-03-01-2022-04-01.xlsx"
from openpyxl import load_workbook from openpyxl import load_workbook
workbook = load_workbook(FILE_NAME) workbook = load_workbook(FILE_NAME)
sheet1 = workbook["PFAC Orders"] sheet1 = workbook["transactions-2022-03-01-2022-04"]
sheet2 = workbook["Customer Email"] sheet2 = workbook["export-20220321-001250"]
gymnast_col = sheet1['J'] gymnast_col = sheet1[SOURCE_GYMNAST_COL]
keepcharacters = [" "]; keepcharacters = [" "];
@ -35,14 +39,14 @@ for cell in gymnast_col:
for row in sheet1.iter_rows(min_row=2): for row in sheet1.iter_rows(min_row=2):
for cell in row: for cell in row:
if cell.column_letter == "H": if cell.column_letter == SOURCE_ID_COL:
customerId = cell.value customerId = cell.value
for target_row in sheet2.iter_rows(min_row=2): for target_row in sheet2.iter_rows(min_row=2):
for target_cell in target_row: for target_cell in target_row:
if target_cell.column_letter == "A": if target_cell.column_letter == TARGET_ID_COL:
targetCustomerId = target_cell.value targetCustomerId = target_cell.value
if customerId == targetCustomerId: if customerId == targetCustomerId:
emailAddress = target_cell.offset(column=1).value emailAddress = target_cell.offset(column=-1).value
cell.offset(column=1).value = emailAddress cell.offset(column=1).value = emailAddress
workbook.save(FILE_NAME) workbook.save(FILE_NAME)