近期有遇到了一个Excel的需求,因Excel文件太多,想着简化工作,通过Python进行数据处理。#!/usr/bin/env python
# -*- coding: utf-8 -*-
[email protected]: 2020/3/26 15:13
[email protected]: Zhanxing
[email protected]:
[email protected]: 修改.py
[email protected]: PyCharm
import openpyxl
def run(excel_file, new_file):
wb = openpyxl.load_workbook(excel_file)
ws = wb.get_sheet_names()
print(ws)
for sheet in ws:
line = wb.get_sheet_by_name(sheet)
for row in line.iter_rows(min_row=2):
for cell in row:
if '点播' == cell.value:
line.cell(row=cell.row, column=cell.column, value='视频')
elif '点播短' == cell.value:
line.cell(row=cell.row, column=cell.column, value='视频')
elif '直播' == cell.value:
line.