Question: Write a easy python code for the file makedocs.py holds a script that when run will create a set of randomized invoices in the form
Write a easy python code for 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 The python code should be without pandas and all the path addresses should be mentioned for my reference. if possible attach pictures too.
code for makedocs.py
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 excel file is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
