import openpyxl
import json
wb = openpyxl.load_workbook("/Users/kcl/Desktop/test.xlsx")
print('输出文件所有工作表名:\n', wb.sheetnames)
ws = wb['APP埋点事件']
for index, i in enumerate(ws.iter_rows(min_row=2, min_col=3)):
print(index)
values = [cell.value for cell in i]
if not values[2] is None:
dict_json = json.loads(values[2])
if dict_json:
value = dict_json['eventId']
dict_json['eventId'] = values[1]
str_json = json.dumps(dict_json)
print(str_json)
ws.cell(row =index+2, column=6).value = str_json
wb.save("/Users/kcl/Desktop/test.xlsx")
网友评论