Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 836099a5dc |
29
main.py
29
main.py
@@ -1,25 +1,22 @@
|
|||||||
#### Test version attempts to parse both the total cost and print quantity from the PDFs. There were some issues with the print qty location moving. So, I went with the manually entered qty break option to get started
|
|
||||||
### This version is also lacking the mailing price logic
|
|
||||||
|
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
import fitz
|
import fitz
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
|
|
||||||
|
doc = fitz.open("std.pdf")
|
||||||
|
# doc = fitz.open("flyers.pdf")
|
||||||
|
# doc = fitz.open("poster.pdf")
|
||||||
|
|
||||||
####### IMPORT MAILING RATE SECTION #########
|
####### IMPORT MAILING RATE SECTION #########
|
||||||
psFCrate = '.55'
|
psFCrate = '.55'
|
||||||
psSCrate = '.44'
|
psSCrate = '.44'
|
||||||
psFCcutoff = '200'
|
psFCcutoff = '200'
|
||||||
|
|
||||||
|
|
||||||
# doc = fitz.open("std.pdf")
|
|
||||||
doc = fitz.open("flyers.pdf")
|
|
||||||
|
|
||||||
count = doc.pageCount
|
count = doc.pageCount
|
||||||
currentPage = 0
|
currentPage = 0
|
||||||
currentBreak = 1
|
currentBreak = 1
|
||||||
|
|
||||||
|
|
||||||
qtyrow = ['Price Input', 'Type', 'Comparisons', 'Options', 'Fixed Costs']
|
qtyrow = ['Price Input', 'Type', 'Comparisons', 'Options', 'Fixed Costs']
|
||||||
costrow =['Base','','','(none)','\"0\"']
|
costrow =['Base','','','(none)','\"0\"']
|
||||||
mailrow = ['OptionalDataList','FormFilling','Equals','yes','\"0\"']
|
mailrow = ['OptionalDataList','FormFilling','Equals','yes','\"0\"']
|
||||||
@@ -58,12 +55,7 @@ while currentPage < count:
|
|||||||
Totalrect = (559.75, 551.71728515625, 584.52099609375, 560.7664794921875) #compontent price not total price
|
Totalrect = (559.75, 551.71728515625, 584.52099609375, 560.7664794921875) #compontent price not total price
|
||||||
Mailingrect = (555.25, 172.9172821044922, 584.5245971679688, 181.9665069580078) #component price for mailing component
|
Mailingrect = (555.25, 172.9172821044922, 584.5245971679688, 181.9665069580078) #component price for mailing component
|
||||||
|
|
||||||
# Find the print quantity on each page
|
|
||||||
qty = [w for w in words if fitz.Rect(w[:4]).intersects(Qtyrect)]
|
|
||||||
qty.sort(key=itemgetter(3, 0))
|
|
||||||
group = groupby(qty, key=itemgetter(3))
|
|
||||||
for y1, gwords in group:
|
|
||||||
totalqty = (" ".join(w[4] for w in gwords))
|
|
||||||
# Find the total job cost on each page
|
# Find the total job cost on each page
|
||||||
total = [w for w in words if fitz.Rect(w[:4]).intersects(Totalrect)]
|
total = [w for w in words if fitz.Rect(w[:4]).intersects(Totalrect)]
|
||||||
total.sort(key=itemgetter(3, 0))
|
total.sort(key=itemgetter(3, 0))
|
||||||
@@ -104,7 +96,6 @@ while currentPage < count:
|
|||||||
currentBreak = currentBreak - 1
|
currentBreak = currentBreak - 1
|
||||||
|
|
||||||
currentPage = currentPage+1
|
currentPage = currentPage+1
|
||||||
|
|
||||||
# Add the weight sections after all the qty breaks
|
# Add the weight sections after all the qty breaks
|
||||||
qtyrow.append('Unit Weight')
|
qtyrow.append('Unit Weight')
|
||||||
qtyrow.append('Tare Weight')
|
qtyrow.append('Tare Weight')
|
||||||
@@ -125,10 +116,4 @@ with open('pricetable.csv', 'w', newline='') as f:
|
|||||||
writer.writerow(qtyrow)
|
writer.writerow(qtyrow)
|
||||||
writer.writerow(costrow)
|
writer.writerow(costrow)
|
||||||
if checkMail is True:
|
if checkMail is True:
|
||||||
writer.writerow(mailrow)
|
writer.writerow(mailrow)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user