Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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