consolidator
/
make_dump2.py
26 строк · 1.1 Кб
1import glob2import ntpath3import pandas as pd4from MyConfig import MyConfig5
6if __name__=="__main__":7try:8settings = MyConfig("consolidation.json")9handlers:list = settings.get("handlers",[])10shop = "prokat_z930"11input_file = "D:\\work\\Укрупнение\\current\\debug_data\\[прокат][Z930].xlsx"12out_pattern ="D:\\work\\Укрупнение\\current\\debug_data2\\"13mapping=pd.read_excel("D:\\work\\Укрупнение\\current\\справочники4\\Маппинг производств.xlsx")14df = pd.read_excel(input_file)15df = df.merge(mapping,left_on="Производство",right_on="Производство",how="left")16
17for item in handlers:18dfh:pd.DataFrame = df[df["Производство2"]==item["key"]]19if not dfh.empty:20dfh.drop("Производство2",axis=1,inplace=True)21dfh.to_excel(f"{out_pattern}{shop}_{item['module']}.xlsx",index=False)22print(f"{item['key']} : {item['module']} : done")23
24
25except Exception as exp:26print(f"error: {exp}")