Spaces:
Running on Zero
Running on Zero
Delete parsers/systemax.py
#2
by vishakhad30 - opened
- parsers/systemax.py +0 -63
parsers/systemax.py
DELETED
|
@@ -1,63 +0,0 @@
|
|
| 1 |
-
import re
|
| 2 |
-
from .common import clean
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
def parse(text):
|
| 6 |
-
"""Systemax packing lists stack labels first, then values.
|
| 7 |
-
|
| 8 |
-
Typical block after "Your PO #":
|
| 9 |
-
Order No. / FOB Point / Order Date / Freight / Ship Via
|
| 10 |
-
UPS GROUND, Acct#...
|
| 11 |
-
9/8/2026
|
| 12 |
-
Quantity Model Description
|
| 13 |
-
<PO>
|
| 14 |
-
<Order No GH...>
|
| 15 |
-
"""
|
| 16 |
-
rows = []
|
| 17 |
-
blocks = re.split(r"Your\s+PO\s*#", text, flags=re.I)
|
| 18 |
-
|
| 19 |
-
for block in blocks[1:]:
|
| 20 |
-
window = block[:900]
|
| 21 |
-
|
| 22 |
-
ship = ""
|
| 23 |
-
sm = re.search(
|
| 24 |
-
r"Ship\s+Via\s*\n\s*([A-Z][^\n]{1,80})",
|
| 25 |
-
window,
|
| 26 |
-
re.I,
|
| 27 |
-
)
|
| 28 |
-
if sm:
|
| 29 |
-
ship = clean(sm.group(1))
|
| 30 |
-
# Drop trailing account noise if needed but keep carrier.
|
| 31 |
-
ship = re.sub(r",\s*Acct#.*$", "", ship, flags=re.I).strip() or clean(sm.group(1))
|
| 32 |
-
|
| 33 |
-
date = ""
|
| 34 |
-
dm = re.search(
|
| 35 |
-
r"Ship\s+Via\s*\n\s*[^\n]+\n\s*(\d{1,2}/\d{1,2}/\d{2,4})",
|
| 36 |
-
window,
|
| 37 |
-
re.I,
|
| 38 |
-
)
|
| 39 |
-
if dm:
|
| 40 |
-
date = clean(dm.group(1))
|
| 41 |
-
else:
|
| 42 |
-
dm = re.search(r"(\d{1,2}/\d{1,2}/\d{2,4})", window)
|
| 43 |
-
if dm:
|
| 44 |
-
date = clean(dm.group(1))
|
| 45 |
-
|
| 46 |
-
po = ""
|
| 47 |
-
after_qty = re.split(r"Quantity\s+Model\s+Description", window, flags=re.I)
|
| 48 |
-
if len(after_qty) > 1:
|
| 49 |
-
tokens = re.findall(r"[A-Z0-9][A-Z0-9._/-]{2,30}", after_qty[1], re.I)
|
| 50 |
-
for tok in tokens:
|
| 51 |
-
tok = clean(tok)
|
| 52 |
-
if re.fullmatch(r"(?:GH|GN|WI)\d{6,}", tok, re.I):
|
| 53 |
-
continue
|
| 54 |
-
if re.fullmatch(r"\d{1,2}/\d{1,2}/\d{2,4}", tok):
|
| 55 |
-
continue
|
| 56 |
-
if re.search(r"\d", tok):
|
| 57 |
-
po = tok
|
| 58 |
-
break
|
| 59 |
-
|
| 60 |
-
if po or ship or date:
|
| 61 |
-
rows.append({"PO Number": po, "Ship Via": ship, "Order Date": date})
|
| 62 |
-
|
| 63 |
-
return rows
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|