Python: 练习 Excel 删除某列数据Python: 练习 Excel 删除某列数据Python: 练习 Excel 删除某列数据Python: 练习 Excel 删除某列数据
  • 首页
  • 博客
  • 文件
  • 书签
  • 分析
  • 登录
Search
Generic filters

Python: 练习 Excel 删除某列数据

Published by admin at 2022年6月10日
Categories
  • Practice
Tags
from openpyxl import *
import os


def modify_file():
    file_list = os.listdir(cwd)
    for file in file_list:
        if os.path.isfile(file):
            print(f"公司:{file} 文件修改 >>> ", end="")
            wb = load_workbook(file)
            ws_name=wb.sheetnames[0]
            ws = wb[ws_name]
            ws.delete_cols(1)  # 删除第 13 列数据
            ws['A1'].comment = None
            wb.save(file)
            print(f"OK!")
    print("全部完成")


if __name__ == '__main__':
    os.chdir("../files")
    cwd = os.getcwd()
    dir_confirm = input(f"工作目录 {cwd},是否正确(y/n):")
    if dir_confirm == "y":
        modify_file()

发表回复 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Categories

  • 猫
  • Python
  • MySQL
  • Django
  • Html/CSS
  • JavaScript
  • Vue
  • RegExp
  • php
  • Practice
  • Virtualization
  • Linux
  • Windows
  • Android
  • NAS
  • Software
  • Hardware
  • Network
  • Router
  • Office
  • WordPress
  • SEO
  • English
  • Games
  • Recipes
  • living
  • Memorandum
  • Essays
  • 未分类

归档

©2015-2022 Alaica Blog support@alaica.com