This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import PyMuPDF library | |
import fitz | |
# Open the PDF file | |
doc = fitz.open('documentprocessing.pdf') | |
# Define new metadata | |
new_metadata = { | |
'author': 'Document Processing', | |
'title': 'Test Document', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import necessary libraries for PDF processing | |
import pdfplumber | |
from pdfplumber.utils.pdfinternals import resolve_and_decode, resolve | |
from pprint import pprint | |
# Open the PDF document for processing | |
pdf = pdfplumber.open("form_pdf.pdf") | |
# Define a helper function to parse form fields recursively |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from docx import Document | |
document = Document() | |
document.save('test.docx') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from docx import Document | |
document = Document('existing-docx-file.docx') | |
document.save('save-with-new-file-name.docx') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from docx import Document | |
document = Document() | |
document.add_picture('file-name-of-image.png') | |
document.save('docx with image from file.docx') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table = document.add_table(rows=2, cols=2) | |
//access the cell at first row and second column | |
cell = table.cell(0, 1) | |
//insert some text | |
cell.text = 'Document Processing' | |
//Add a new row to the table | |
row = table.add_row() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This example creates a new XLS file from scratch and saves it to disc | |
import pyexcel as p | |
#open a sample Excel file | |
sheet = p.get_sheet(file_name="example.xls") | |
#save as empty Excel file | |
sheet.save_as("emptyExcelFile.xls") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyexcel as p | |
#open a sample Excel file | |
sheet = p.get_sheet(file_name="example.xls") | |
##add row to the Excel file with values | |
sheet.row += [12, 11] | |
sheet.save_as("addNewRowToXLS.xls") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyexcel as p | |
#open a sample Excel file | |
sheet = p.get_sheet(file_name="example.xls") | |
#add a new column to an existing Python file | |
sheet.column += ["Column 3", 10, 11, 12] | |
#save the file to disc | |
sheet.save_as("addNewColumn.xls") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyexcel as p | |
#open a sample Excel file | |
sheet = p.get_sheet(file_name="example.xls") | |
#update data in existing column | |
sheet.column[2] = ["Column 3", 100, 200, 300] | |
#Save XLS file to disc | |
sheet.save_as("updateexisting.xls") |