Example #1
0
def printOutput(text_string,target_pdf,i): #4th arg - write priviledges?
    #print "entered printoutput1"
    outputFile=target_pdf[:target_pdf.rindex('.')]+' Text Output.txt'
    filename=useful.getFilenameFromPath(target_pdf)
    filehandle=file(outputFile,'a')
    filehandle.write("TEXT FROM "+str(filename)+" PAGE "+str(i))
    filehandle.write("\n")
    filehandle.write(text_string)
    filehandle.write('\n')
    return outputFile
Example #2
0
def print_by_account_number(library,refined_results,text_file):

    ## Openpyxl library imports
    from openpyxl import Workbook
    from openpyxl import load_workbook

    ## Get the excel filename from the name of the text file that the user navigated to
    book_name=useful.getFilenameFromPath(text_file)+'.xlsx'

    try: ## Try opening the workbook with the same name"
        wb=load_workbook(book_name)
    except: ## If it doesn't exist then start a new workbook in memory
        wb = Workbook()

    ## This match business is to try and sort the gathered data by account number, but the account numbers
    ## aren't really reliable enough, so I think I'm going to stop doing this for now. 
    match=0
    for entry in refined_results:
        
        sheet_names=wb.get_sheet_names()
        for item in sheet_names:
            if entry['Account Number']==item:
                match=1
            else:
                pass
        if match==1:
            ws=wb.get_sheet_by_name(entry['Account Number'])
            last_occ_row=ws.rows[-1][0].row
            i=0
            for key in library['library_info']['heading_order']:
                c=ws.cell(row=last_occ_row, column=i)
                c.value=entry[key]
                i=i+1
        else:
            newSheet=wb.create_sheet()
            newSheet.title = str(entry['Account Number'])
            i=0
            for key in library['library_info']['heading_order']:
                c=newSheet.cell(row=0, column=i)
                d=newSheet.cell(row=1, column=i)
                c.value=key
                d.value=entry[key]
                i=i+1
        match=0
            
    wb.save(book_name)
    return book_name
Example #3
0
def print_by_none(library,refined_results,text_file):

    ## Openpyxl library imports
    from openpyxl import Workbook
    from openpyxl import load_workbook

    ## Get the excel filename from the name of the text file that the user navigated to
    book_name=useful.getFilenameFromPath(text_file)+'.xlsx'

    try: ## Try opening the workbook with the same name"
        wb=load_workbook(book_name)
        new_wb=-1
        ws = wb.get_active_sheet()
        
    except: ## If it doesn't exist then start a new workbook in memory
        wb = Workbook()
        ws = wb.get_active_sheet()
        new_wb=1
        i=0
        for key in library['library_info']['heading_order']:
            c=ws.cell(row=0, column=i)
            c.value=key
            i=i+1
    
    for entry in refined_results:
    
        last_occ_row=ws.rows[-1][0].row

        i=0
        for key in library['library_info']['heading_order']:
            c=ws.cell(row=last_occ_row, column=i)
            c.value=entry[key]
            i=i+1
            
    wb.save(book_name)
    return book_name