【Python】クリック一発でファイルをフォルダに整理する

    サンプルファイルは下らダウンロード

    name_sort.py
    from concurrent.futures.thread import _worker
    import pandas as pd
    import glob
    import os
    import datetime
    
    branch_dic={}
    branch_dic["横浜支店"]="????????y.xlsx"
    branch_dic["名古屋支店"]="????????n.xlsx"
    branch_dic["大阪支店"]="????????o.xlsx"
    
    def file_control(branch_name):
    for excel_filename in glob.glob(branch_dic[branch_name]):
    df=pd.read_excel(excel_filename)
    work_filename=excel_filename.split(".")
    save_filename=work_filename[0]+\
    str(datetime.date.today())+"."+work_filename[1]
    save_path_filename=os.path.join(os.getcwd(),branch_name,save_filename)
    with pd.ExcelWriter(save_path_filename) as writer:
    df.to_excel(writer,index=False)
    os.remove(excel_filename)
    
    file_control("横浜支店")
    file_control("名古屋支店")
    file_control("大阪支店")
    よかったらシェアしてね!
    • URLをコピーしました!
    目次