Esempio n. 1
0
def delfile(ADD):

    all_file = os_file.open(self=ADD, all=1)
    #print("正在分析", all_file)
    for per_file in all_file:
        #print(per_file)
        os.remove(per_file)
Esempio n. 2
0
def tax_main_(ADD):
    s=""
    all_file = os_file.open(self=ADD, all=1)
    # print(len(all_file))
    if len(all_file) > 0:
        for per_file in all_file:
            print("读取", per_file)
            # print(per_file)
            sheet_0 = OpenExcel.open_excel_sheet(per_file, sheet=0)
            try:
                row_1 = OpenExcel.open_excel_row(per_file, sheet=0, row=1)  # row=1 第二行
                tostr = ListToStr.tostr(DataSum.row_sum(rows=row_1, sheet=sheet_0))  # 转成文本
            # print("sheet",sheet_0)
            # print("row", row_1)
            #print(type(DataSum.row_sum(rows=row_1, sheet=sheet_0)))
            except:
                #os.remove(per_file)
                tostr = "格式不对<br>"
            #logging.info(tostr)
            #return tostr
            s=s+per_file+"<br>"+tostr+"<br>"
            #logging.info(s)
            # return DataSum.row_sum(rows=row_1, sheet=sheet_0)
    else:
        return "找不到文件"
        print("已计算%s份文件的税金" % len(all_file))
    return s
Esempio n. 3
0
def formast(ADD):
    all_file = os_file.open(self=ADD, all=1)
    try:
        for per_file in all_file:
            if per_file[-4:] == ".xls":
                rb = xlrd.open_workbook(filename=per_file)
                wb = xl_copy(rb)
                wb.save(per_file + "x")
                logging.info(per_file + "--转换成功")
                os.remove(per_file)
    except Exception as e:
        raise e
Esempio n. 4
0
def New_Sheet(ADD, sheetname):
    """
    :param add: 地址
    :param sheetname: 工作页的命名
    :return:
    """
    all_file = os_file.open(self=ADD, all=1)
    for per_file in all_file:
        print("分析结果", per_file)

        rb = xlrd.open_workbook(filename=per_file)
        wb = xl_copy(rb)
        wb.add_sheet(sheetname=sheetname)
        wb.save(per_file + "x")

        print('succeed')
Esempio n. 5
0
def build_waybill():
    ADD = "E:/HUMEI/Excel_shunxu/检测1/"
    ADD_none = r"E:\HUMEI\Excel_shunxu\空表\none.xls"
    ADD_waybill = "E:/HUMEI/Excel_shunxu/顺序模板/waybill_0.xlsx"

    all_file = os_file.open(self=ADD, all=1)
    #print("正在分析", all_file)
    row_waybill = OpenExcel.open_excel_row(ADD_waybill, sheet=0, row=0)
    #print("row_waybill", row_waybill)
    logging.info("生成运单OK")

    p = 0
    for per_file in all_file:

        #print("waybill.py", p, per_file)

        # workbook = xlrd.open_workbook(filename=per_file)
        workbook_none = xlrd.open_workbook(filename=ADD_none)
        wb = xl_copy(workbook_none)
        # wb.add_sheet("waybill")

        try:
            s = wb.get_sheet(0)


        except:
            print("错误:请新建Sheet")

        sheet_0 = OpenExcel.open_excel_sheet(per_file, sheet=0)
        row_1 = OpenExcel.open_excel_row(per_file, sheet=0, row=0)
        #print(row_1)

        for i in range(23):

            a = 0
            for x in RowData.row_name(row_waybill[i], row_1, sheet_0):
                s.write(a, i, x)
                a = a + 1
        new_name = re.findall("/检测1/(.+)_20", per_file)
        #print(new_name)
        nowTime = datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
        #print(nowTime)
        p = p + 1
        wb.save("E:/HUMEI/Excel_shunxu/检测3/" + "%s waybill_%s.xls" % (new_name[0], p))
        # wb.save("E:/HUMEI/Excel_shunxu/检测3/" + "%s.xls" % new_name)
        wb.save("E:/HUMEI/Excel_shunxu/转发1/" + "%s waybill_%s.xls" % (new_name[0], p))
Esempio n. 6
0
def run(src_path, target_path, txt):
    file_list = os.listdir(target_path)
    if len(file_list) > 0:
        for file in file_list:
            logging.info(file)

    all_file = os_file.open(self=src_path, all=1)
    if len(all_file) > 0:
        for per_file in all_file:
            #logging.info(per_file)
            if txt in per_file:
                logging.info("OK  " + str(per_file))

                filename = re.findall(r"/2020-07/(.*)", str(per_file))
                #logging.info(filename)
                shutil.move(str(per_file), target_path + filename[0])

    else:
        logging.info("文件夹是空的")
Esempio n. 7
0
def run(src_path, txt):
    all_file = os_file.open(self=src_path, all=1)
    if len(all_file) > 0:
        s = ""
        for per_file in all_file:
            #logging.info(per_file)
            if txt in per_file:
                logging.info("OK  " + str(per_file))
                filename = re.findall(r"/2020-07/(.*)", str(per_file))
                logging.info(type(filename))
                s = s + filename[0] + "<br>"
                #logging.info(s)

    if s == "":
        logging.info("找不到文件")
        return "找不到文件 请通过微信发送文件"
    else:
        logging.info(s)
        return s
Esempio n. 8
0
def run(ADD):
    # ADD = "E:/HUMEI/Excel_shunxu/转发1/"

    all_file = os_file.open(self=ADD, all=1)
    #print("正在分析", all_file)

    if len(all_file) > 0:  # 判断是否有文件
        zip = zipfile.ZipFile(ADD + "file.zip", "w", zipfile.ZIP_DEFLATED)
        p = 0
        for per_file in all_file:
            logging.info(per_file)
            zip.write(per_file)
            logging.info(zip.write(per_file))

            #time.sleep(5)
            logging.info("%s is OK" % per_file)
    #else:
    #logging.info("不存在文件")
    zip.close()
    baidu.send(ADD + "file.zip")
Esempio n. 9
0
def build_bill(ADD):
    # ADD = "E:/HUMEI/Excel_shunxu/检测/"
    ADD_none = r"E:\HUMEI\Excel_shunxu\空表\none.xls"
    ADD_changebill = "E:/HUMEI/Excel_shunxu/顺序模板/changebill_0.xls"

    all_file = os_file.open(self=ADD, all=1)
    # print("正在分析", all_file)
    row_changebill = OpenExcel.open_excel_row(ADD_changebill, sheet=0, row=0)
    # print(row_changebill)

    if len(all_file) > 0:  # 判断是否有文件

        p = 0
        for per_file in all_file:

            print("┌ 清单后期处理----Star")
            print("├", per_file)
            workbook_nome = xlrd.open_workbook(filename=ADD_none)
            wb = xl_copy(workbook_nome)
            try:
                s = wb.get_sheet(0)
            except:
                print("错误:请新建Sheet")
            sheet_0 = OpenExcel.open_excel_sheet(per_file, sheet=0)  # 读取第一个工作
            row_1 = OpenExcel.open_excel_row(per_file, sheet=0,
                                             row=0)  # 读取第一个工作页第一行
            # print(row_1)
            for i in range(45):
                a = 0
                for x in RowData.row_name(row_changebill[i], row_1, sheet_0):
                    s.write(a, i, x)
                    a = a + 1

            xun_hao(RowData.row_name("订单编号", row_1, sheet_0),
                    s)  # 【引用内部函数0】序号重新排序函数
            city_num(RowData.row_name("收件人所在省*", row_1, sheet_0),
                     s)  # 【引用内部函数1】省市代码转换函数
            shu_liang(RowData.row_name("第二法定数量*", row_1, sheet_0),
                      s)  # 【引用内部函数2】去掉0
            firstrowname(
                OpenExcel.open_excel_row(ADD_changebill, sheet=0, row=1),
                s)  # 【引用内部函数3】表头名字更正
            heavy(RowData.row_name("净重", row_1, sheet_0),
                  RowData.row_name("毛重*", row_1, sheet_0),
                  RowData.row_name("申报数量*", row_1, sheet_0),
                  s)  # 【引用内部函数4】毛重净总按销量乘积
            mao_heavy_sum(RowData.row_name("订单编号", row_1, sheet_0),
                          RowData.row_name("毛重*", row_1, sheet_0),
                          RowData.row_name("申报数量*", row_1, sheet_0),
                          s)  # 【引用内部函数6】相同订单的毛重合计

            new_name = re.findall("/检测/(.+).xls", per_file)
            # print(new_name)
            nowTime = datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
            # print(type(nowTime))
            # print(RowData.row_name("序号", row_1, sheet_0))
            # wb.save("E:/HUMEI/Excel_shunxu/检测1/"+"changebill_%s.xls" % nowTime)
            p = p + 1
            wb.save("E:/HUMEI/Excel_shunxu/检测1/" + "%s_%s %s.xls" %
                    (new_name[0], nowTime, p))
            wb.save("E:/HUMEI/Excel_shunxu/检测3/" + "%s_%s %s.xls" %
                    (new_name[0], nowTime, p))
            wb.save("E:/HUMEI/Excel_shunxu/转发1/" + "%s_%s %s.xls" %
                    (new_name[0], nowTime, p))
        print("清单生成----OK")
    else:
        logging.info("生成%s份清单文件" % len(all_file))
        #print()
        return "生成%s份清单文件" % len(all_file)