Exemplo n.º 1
0
        interpreter = PDFPageInterpreter(rsrcmgr, device)
        for page in PDFPage.create_pages(doc):
            interpreter.process_page(page)

    return output_string.getvalue()


# root_path = os.path.normpath("J:/32_IZ224_SIEMENS_Herne/60_Construction/10_Sx_Input/30_Sx_Project_Documentation/10_Mechanical_Engineering_Project/40_Piping_Iso")
root_path = os.path.normpath("D:/00_herne/test/workfiles")
#save_path = os.path.normpath("D:/00_herne/01_py_script_export/sys")
#file_name = "pdf_extracted_br"
time_now = datetime.now().strftime("%Y-%m-%d_%H%M%S")
search_for = "BR"
exclude = ["00_Archive", "01_Archive", "00_Document_templates"]
log_file = "log_error"
log = log.get_logger(log_file)

xls_file = "D:/00_herne/00_ISO_list_2020-10-01.xlsx"
wb = load_workbook(xls_file, read_only=False)
sh1 = wb["ISO_LIST"]  # isometric line list

line_list = next(i for i in sh1.iter_cols(
    min_row=1, max_row=2970, min_col=1, max_col=1))  # line kks list

data = {
    "KKS": [],
    "REV": [],
    "DATE": [],
    "FILE": [],
    "PATH": [],
    "KKS_connected": [],
Exemplo n.º 2
0
dlist = dl.dir_list(root_path,
                    obj_type="f",
                    src_for="60*BR*",
                    ext="pdf",
                    exclude=exclude_dir)  # list of required files

wb_save_path = Path("D:\\00_HERNE\\_tracking\\")  # workbook save path
wb_file_name = "deleted_lines_pdf_parsed_support_list"  # workbook save filename
wb_rev = "00"  # workbook revision
wb = Workbook()  # workbook
ws = wb.active  # workbook sheet activate
r = 1  # initial row number

log_file = "error_logfile"
log = log.get_logger(f"{wb_file_name}_{log_file}")

for file in dlist:
    try:
        raw_pdf_data = pdf_parser.parse(file)
        raw_str_list = list(map(str, raw_pdf_data.split()))
        pattern = r"(\d\d)(BQ)"
        for string in raw_str_list:
            if re.search(pattern, string):
                ws.cell(r, 1, f'=HYPERLINK("{file}","Open")')
                ws.cell(r, 2, file.parts[-2])  # system
                ws.cell(r, 3, file.stem.split("_")[0])  # KKS
                ws.cell(r, 4, file.stem.split("_")[1])  # UNID
                ws.cell(r, 5, file.stem.split("_")[-1][-1])  # revision
                ws.cell(
                    r, 6,
Exemplo n.º 3
0
import os
import re
import pandas as pd
from openpyxl import Workbook, load_workbook
from datetime import datetime
from win32com import client
import logging
import logging_error

path = "D:/00_herne/01_py_script_export/logs"
file_name = "testiranje"

logger = logging_error.get_logger(file_name)

# logging.basicConfig(level=logging.DEBUG, format='%(levelname)s - %(asctime)s - %(message)s', datefmt='T(%d.%m.%Y. %H:%M)')

a = 2
b = 0
for i in range(a):
    try:
        print(i / b)
    except Exception as error:
        logger.exception(f"{error}", exc_info=False)
Exemplo n.º 4
0
log_file = "VT_bulk_print"
log_path = "D:/00_herne/01_py_script_export/logs"
exclude = ["00_Archive", "01_Archive",
           "00_Document_templates"]  # excluded folders

wb = load_workbook(xls_file, read_only=False)
sh1 = wb.worksheets[0]  # Template
sh2 = wb.worksheets[1]  # Weldmap
sh3 = wb.worksheets[2]  # Linelist

ref_vt_list = get_vt_list(root_path)  # list of kks with VT file
weldmap_kks = next(i for i in sh2.iter_cols(
    min_row=2, max_row=7305, min_col=1, max_col=1))  # weldmap kks list
linelist_kks = next(i for i in sh3.iter_cols(
    min_row=2, max_row=2952, min_col=1, max_col=1))  # line kks list

logger = logging_error.get_logger(log_file)

for kks in ref_vt_list:
    try:
        vt_temp(kks)
        wb_dst = os.path.join(kks, f"{os.path.basename(kks)}.xlsx")
        replace_sheet(xls_file, wb_dst)
        pdf_file = os.path.join(kks, f"06_1_VT.pdf")
        export_pdf(xls_file, pdf_file)
    except Exception as error:
        logger.exception(f"{kks} -- {error}", exc_info=True)

wb.close()
del ref_vt_list, weldmap_kks, linelist_kks