Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is the python make docx file from docx import Document import random import math def makeInvoices ( numFiles ) : products = [
This is the python make docx file from docx import Document import random import math def makeInvoicesnumFiles: products Parka "Boots", "Snowshoes", "Climbing Rope", "Oxygen Tank", "Ice Pick", "Crampons" # Invoice loop for i in rangenumFiles: # Create Randomized invoice invoiceNum strizfill productList for j in rangerandomrandint: product productsrandomrandintlenproducts if product in productList: productListproduct else: productListproduct subtot roundrandomrandomrandomrandint tax roundsubtot total roundsubtot tax, # Create doc from random invoice aDoc Document aDoc.addheadingINV invoiceNum pProd aDoc.addparagraphPRODUCTS for key in productList.keys: pProd.addrunfkey:productListkey aDoc.addparagraphfSUBTOTAL:subtot TAX:tax TOTAL:total aDoc.savefINVinvoiceNumdocx" makeInvoices The question is the file makedocs.py holds a script that when run will create a set of randomized invoices in the form of word documents. your task is to create a python script that processes all docx files created into a single spreadsheet that has a row for each invoice and columns for: invoice id total number of products purchased, subtotal, tax, and total. the file aexxslx contains an example spreadsheet. read documents extract data write spreadsheets and the excel table given is
This is the python make docx file from docx import Document
import random
import math
def makeInvoicesnumFiles:
products Parka "Boots", "Snowshoes", "Climbing Rope", "Oxygen Tank", "Ice Pick", "Crampons"
# Invoice loop
for i in rangenumFiles:
# Create Randomized invoice
invoiceNum strizfill
productList
for j in rangerandomrandint:
product productsrandomrandintlenproducts
if product in productList:
productListproduct
else:
productListproduct
subtot roundrandomrandomrandomrandint
tax roundsubtot
total roundsubtot tax,
# Create doc from random invoice
aDoc Document
aDoc.addheadingINV invoiceNum
pProd aDoc.addparagraphPRODUCTS
for key in productList.keys:
pProd.addrunfkey:productListkey
aDoc.addparagraphfSUBTOTAL:subtot
TAX:tax
TOTAL:total
aDoc.savefINVinvoiceNumdocx"
makeInvoices
The question is
the file makedocs.py holds a script that when run will create a set of randomized invoices in the form of word documents. your task is to create a python script that processes all docx files created into a single spreadsheet that has a row for each invoice and columns for: invoice id total number of products purchased, subtotal, tax, and total. the file aexxslx contains an example spreadsheet. read documents extract data write spreadsheets
and the excel table given is
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started