2022-12-12

python with child substitute

# 제품명에 [심층] 들어간 것을 [심층]은 빼고 제품명만 나오게 치환하기

from openpyxl import load_workbook
from openpyxl.utils import get_column_letter

rxl = load_workbook(r'2022bj.xlsx')
rs= rxl.active
col_max= rs.max_column
row_max= rs.max_row
col_num=6 # product name

for row_num in range(1, row_max+1):
    tmpstr= str(rs.cell(row= row_num, column= col_num).value)
    data = tmpstr.replace(" [심층]", "")
    rs.cell(row= row_num, column= col_num).value = data

rxl.save("22plan.xlsx")
rxl.close()

댓글 없음:

댓글 쓰기