示例#1
0
def finalizer(filed=[]):
    files = [
        "static/merge/planning and organising.docx",
        "static/merge/customer service.docx", "static/merge/leadership.docx",
        "static/merge/commercial awareness.docx",
        "static/merge/initiative.docx",
        "static/merge/persuasive oral communication.docx"
    ]
    output_doc = Document("static/merge/nicopon.docx")
    for file in filed:
        if file in files:
            pass
        else:
            files.append(file)
    for index, file in enumerate(files):
        try:
            input_doc = Document(file)
            paro = 0
            if index < len(files):
                output_doc.add_page_break()
            for para in input_doc.paragraphs:
                get_para_data(output_doc, para, paro)
                paro += 1
        except Exception as e:
            print("mhhh")
            print(e)
    p = output_doc.add_paragraph()
    r = p.add_run()
    r.add_picture('static/end.PNG', width=Inches(7.09), height=Inches(8.76))
    output_doc.save('static/merge/report.docx')
示例#2
0
def merger(docs=[]):
    list_of_data = []
    list_of_names = []
    for z in docs:
        name = z.split(".")
        na = name[0]
        k = na.split("static/merge/")
        na = k[1]
        list_of_names.append(na)
    for x in docs:
        list_of_data.append(read_table(x))


##    print(list_of_names)
##    print(list_of_data)
##    return(0)

    documentx = Document("static/merge/start.docx")
    documentx.add_page_break()
    y = 0
    #print(list_of_data[0][0])
    x = 0
    op = list_of_data
    list_of_comments = []
    k = 0
    m = 0
    while True:
        templist = []
        try:
            for y in op[m]:
                templist.append(y['comments'])
            list_of_comments.append(templist)
        except Exception as e:
            break
        m += 1

    list_of_titles = []
    k = 0
    for x in op:
        templist = []
        for y in op[0]:
            templist.append(y['title'])
        list_of_titles.append(templist)
        k += 1
        list_of_titles = list_of_titles[0]
        break
    post = 0
    for data in list_of_data:
        com = 0
        for z in data[0]:
            xc = len(data[0])
            documentx.add_heading(list_of_titles[post], level=1)
            post += 1
            y = len(list_of_data)
            x = 0
            #print(list_of_comments)
            while x < len(list_of_data):
                print(x, com)
                head = list_of_names[x] + '\n'
                p = documentx.add_paragraph('\n')
                p.add_run(head).bold = True
                p.add_run(list_of_comments[x][com])
                x += 1
            com += 1
            documentx.add_page_break()
        break
    documentx.save('static/merge/report.docx')