#!/usr/bin/env python3 """Generate listings.csv — the individual vendor listings behind containers.csv. containers.csv gives one typical row per nominal size. This gives the raw observations it was generalised from: real SKUs, real prices, the date each was captured, and the usable ratio each one implies. Anyone who disagrees with a typical figure can see the spread it came from. Reads the snapshots in raw/, which are trimmed captures of the vendors' own catalogue endpoints. Re-fetching those files is the only way to refresh; this script never hits the network, so a rebuild always reproduces the same table. Run: python3 build_listings.py """ import csv import json import re from pathlib import Path HERE = Path(__file__).parent RAW = HERE / "raw" IN_TO_CM = 2.54 US_GAL_TO_L = 3.785411784 # vendor, country, currency, prices-include-VAT, unit the catalogue publishes in VENDOR_META = { "hudsonex": ("Hudson Exchange", "US", "USD", False, "imperial"), "plasticboxshop": ("Plastic Box Shop", "GB", "GBP", True, "metric"), } ROWS = [] def add(**kw): # Normalise the metric dimensions to float before anything derives from them. # The hand-written vendor blocks below use int literals where a dimension is a # round number, which wrote "60" into a column that is float64 everywhere else # and broke grouping: "60" and "60.0" are different keys to anyone filtering # the CSV as strings. for f in ("external_length_cm", "external_width_cm", "external_height_cm", "internal_length_cm", "internal_width_cm", "internal_height_cm", "stated_capacity_l"): if kw.get(f) not in (None, ""): kw[f] = float(kw[f]) ext = kw["external_length_cm"] * kw["external_width_cm"] * kw["external_height_cm"] / 1000 cap = kw.get("stated_capacity_l") kw["external_volume_l"] = round(ext, 1) kw["usable_ratio"] = round(cap / ext, 3) if cap and ext else "" # Every row carries both unit systems, whichever the vendor published in. # A US buyer shops in inches and gallons; anyone sizing European shelving or # checking pallet interoperability needs mm. Converting on read means half the # audience does arithmetic before it can compare two rows. # # native_unit records which side of the conversion is the vendor's own figure # and which is derived. It matters: Hudson Exchange designs to inches, so its # 21.9 x 15.2" tote is 55.6 x 38.6 cm — close enough to a 600 x 400 Eurobox to # look like one in a catalogue, and not the same box. # Derive only the side the vendor did not publish. An imperial-native vendor # passes its own inch figures in, because back-converting a cm value that was # itself rounded to 1 dp turns Hudson's own 19.6" into 19.61". for axis in ("length", "width", "height"): cm = kw.get(f"external_{axis}_cm") if not kw.get(f"external_{axis}_in"): kw[f"external_{axis}_in"] = round(cm / IN_TO_CM, 2) if cm else "" icm = kw.get(f"internal_{axis}_cm") if not kw.get(f"internal_{axis}_in"): kw[f"internal_{axis}_in"] = round(icm / IN_TO_CM, 2) if icm else "" kw["stated_capacity_gal"] = round(cap / US_GAL_TO_L, 1) if cap else "" kw["external_volume_gal"] = round(ext / US_GAL_TO_L, 1) if ext else "" ROWS.append(kw) def snapshot(name): return json.loads((RAW / name).read_text(encoding="utf-8")) # --------------------------------------------------------------------------- # Hudson Exchange (US). Dimensions and capacity are in the product title, in # inches and US gallons. No internal dimensions are published — the description # only confirms "tapered interior wall allow for nesting when not in use". # --------------------------------------------------------------------------- snap = snapshot("hudsonex-hudson-exchange-attached-lid-containers-2026-07-27.json") vendor, country, currency, vat, unit = VENDOR_META["hudsonex"] TITLE_RE = re.compile(r'([\d.]+)\s*x\s*([\d.]+)\s*x\s*([\d.]+)\s*["”\']?\s*\(([\d.]+)\s*Gallon\)', re.I) # "Pallet Deal (120 Totes) ..." — the tote count sits in its own parenthetical, # ahead of the dimensions, so it needs a separate pattern from the UK packs. TOTES_RE = re.compile(r'\((\d+)\s*Totes?\)', re.I) for p in snap["products"]: m = TITLE_RE.search(p["title"]) if not m: continue # dollies: no gallon capacity in the title L, W, H, gal = (float(x) for x in m.groups()) straight = "straight wall" in p["title"].lower() totes = TOTES_RE.search(p["title"]) qty = int(totes.group(1)) if totes else 1 price = float(p["price"]) add( listing_id=f"hudsonex-{p['sku'] or p['handle']}", vendor=vendor, vendor_country=country, native_unit=unit, product_name=p["title"], sku=p["sku"] or "", url=p["url"], type="euro_stacking_container" if straight else "attached_lid_container", external_length_cm=round(L * IN_TO_CM, 1), external_width_cm=round(W * IN_TO_CM, 1), external_height_cm=round(H * IN_TO_CM, 1), external_length_in=L, external_width_in=W, external_height_in=H, internal_length_cm="", internal_width_cm="", internal_height_cm="", stated_capacity_l=round(gal * US_GAL_TO_L, 1), stated_capacity_gal=gal, price=price, currency=currency, price_includes_vat=vat, pack_quantity=qty, unit_price=round(price / qty, 2), captured_date=snap["captured_utc"], notes="US-market footprint, not a 600x400 Euro module. Capacity stated in " "US gallons; dimensions in inches" + ("; straight-walled with an attached lid" if straight else "") + ("; pallet lot, unit_price is the per-tote figure" if qty > 1 else ""), ) # --------------------------------------------------------------------------- # Plastic Box Shop (UK). Capacity is in the title; dimensions appear in the # description prose in two different phrasings, and many listings are multi-packs. # --------------------------------------------------------------------------- DIMS_RE = re.compile( r'(internal|external)\s+dimensions?\s*:?\s*' r'([\d.]+)\s*cm\s*\(?[LlWwHh]?\)?\s*x\s*([\d.]+)\s*cm\s*\(?[LlWwHh]?\)?\s*x\s*([\d.]+)\s*cm', re.I) INLINE_EXT_RE = re.compile( r'external dimensions of\s*([\d.]+)\s*cm\s*long\s*x\s*([\d.]+)\s*cm\s*wide\s*x\s*([\d.]+)\s*cm\s*high', re.I) CAP_RE = re.compile(r'([\d.]+)\s*(?:Litre|litre|lt)\b') PACK_RE = re.compile(r'(?:Pack|Pallet(?:\s+Deal)?)\s*(?:of\s*)?x?\s*(\d+)', re.I) for fn, kind in (("plasticboxshop-alc-containers-2026-07-27.json", "attached_lid_container"), ("plasticboxshop-euro-stacking-containers-2026-07-27.json", "euro_stacking_container")): snap = snapshot(fn) vendor, country, currency, vat, unit = VENDOR_META["plasticboxshop"] for p in snap["products"]: blob = p["title"] + " " + (p["description"] or "") dims = {m.group(1).lower(): tuple(float(x) for x in m.groups()[1:]) for m in DIMS_RE.finditer(blob)} if "external" not in dims: m = INLINE_EXT_RE.search(blob) if m: dims["external"] = tuple(float(x) for x in m.groups()) if "external" not in dims: continue # no dimensions published in the listing text cap = CAP_RE.search(p["title"]) pack = PACK_RE.search(p["title"]) qty = int(pack.group(1)) if pack else 1 price = float(p["price"]) ext = dims["external"] internal = dims.get("internal", ("", "", "")) add( listing_id=f"plasticboxshop-{p['handle']}", vendor=vendor, vendor_country=country, native_unit=unit, product_name=p["title"], sku=p["sku"] or "", url=p["url"], type=kind, external_length_cm=ext[0], external_width_cm=ext[1], external_height_cm=ext[2], internal_length_cm=internal[0], internal_width_cm=internal[1], internal_height_cm=internal[2], stated_capacity_l=float(cap.group(1)) if cap else "", price=price, currency=currency, price_includes_vat=vat, pack_quantity=qty, unit_price=round(price / qty, 2), captured_date=snap["captured_utc"], notes="Multi-pack listing; unit_price is the per-box figure" if qty > 1 else "", ) # --------------------------------------------------------------------------- # Yosibox (Israel). Captured 2026-07-23 in a separate research pass, before the # Shopify snapshots above, and transcribed rather than machine-parsed — these are # the listings that anchor the 600x400 internal rule. Prices include 18 % VAT. # --------------------------------------------------------------------------- YOSIBOX = [ # name, ext L/W/H cm, int L/W/H cm or None, stated L, price ILS, item id ("G-4615 industrial box 60x40x15", (60, 40, 15), None, 28, 100, "8484969"), ("G-4617 industrial box 60x40x17.5", (60, 40, 17.5), None, 32, 100, "8579190"), ("G-4623 industrial box 60x40x23", (60, 40, 23), (55, 36, 21.5), 42, 112, "8458664"), ("G-4628 industrial box 60x40x28", (60, 40, 28), None, 52, 124, "8457392"), ("G-4634 industrial box 60x40x34", (60, 40, 34), (55, 36, 32.5), 64, 153, "8488075"), ("G-3415 industrial box 40x30x15", (40, 30, 15), None, 12, 94, "8456001"), ("G-3423 industrial box 40x30x23", (40, 30, 23), None, 19, 106, "8484408"), ("T-4627 industrial box 60x40x27", (60, 40, 27), None, 50, 127, "8496351"), ("T-4631 industrial box 60x40x31.5", (60, 40, 31.5), None, 58, 138, "8419527"), ("T-4636 industrial box 60x40x36.5", (60, 40, 36.5), None, 68, 144, "8418877"), ("T-4641 industrial box 60x40x41.5", (60, 40, 41.5), None, 78, 155, "8388110"), ("6422 industrial box 60x40x23", (60, 40, 23), (55.5, 35.6, 21.6), 42, "", "7689793"), ] for name, ext, internal, cap, price, item in YOSIBOX: i = internal or ("", "", "") add( listing_id=f"yosibox-{item}", vendor="Yosibox", vendor_country="IL", native_unit="metric", product_name=name, sku="", url=f"https://www.yosibox.com/items/{item}", type="euro_stacking_container", external_length_cm=ext[0], external_width_cm=ext[1], external_height_cm=ext[2], internal_length_cm=i[0], internal_width_cm=i[1], internal_height_cm=i[2], stated_capacity_l=cap, # VAT inclusion is a property of the vendor's pricing, not of the individual # listing, so it stays True even on the row whose price was on application. price=price, currency="ILS", price_includes_vat=True, pack_quantity=1, unit_price=price, captured_date="2026-07-23", notes="Transcribed from a manual research pass, not a machine capture. " "Price includes 18 % VAT" + ("" if price != "" else ". Price on application at capture"), ) # --------------------------------------------------------------------------- # Salesbridges (NL). The only vendor here that publishes internal dimensions on # nearly every listing — 70 of 98 — which is what makes it worth the per-product # fetch in scripts/capture_salesbridges.py. Prices are ex-VAT (NL VAT is 21 %). # # Their internal figures are systematically 3 cm under the external on L and W, # i.e. the *top opening*, where Plastic Box Shop and Yosibox quote something # close to the base. Both are honest measurements of a slightly tapered box; # see guidance/internal-dimensions.md. # --------------------------------------------------------------------------- SB_DIMS_RE = re.compile( r'([\d.,]+)\s*[xX×]\s*([\d.,]+)\s*[xX×]\s*([\d.,]+)\s*(mm|cm)?', re.I) SB_CAP_RE = re.compile(r'([\d.,]+)\s*(?:L|litre|liter)\b', re.I) # Footprints the dataset is about. Everything else in the category — trolleys, # dollies, the 99x63.5 bigbox — is filtered out by this rather than by title. EURO_FOOTPRINTS = {(60, 40), (40, 30), (30, 20), (20, 15), (80, 60)} def sb_dims(value): """Parse "600 x 400 x 320 mm" or "57 x 37 x 31,5 cm" to cm.""" m = SB_DIMS_RE.search(value or "") if not m: return None v = [float(x.replace(",", ".")) for x in m.groups()[:3]] unit = (m.group(4) or "").lower() # Unit is omitted about as often as it is given; anything over 200 is mm. if unit == "mm" or max(v) > 200: v = [x / 10 for x in v] return tuple(round(x, 1) for x in v) def sb_spec(specs, *prefixes): for k, v in specs.items(): if k.lower().startswith(prefixes): return v return None # Salesbridges calls ordinary open-top euroboxes "KLT Box" in the title, so the # word alone means nothing. Only the R-KLT / RL-KLT product lines are actual VDA # 4500 carriers, and those are also the only ones with an SBRKLT/SBRLKLT SKU. KLT_RE = re.compile(r'\br-?l?-?klt\b', re.I) snap = snapshot("salesbridges-plastic-crates-2026-07-27.json") seen_ids = {} for p in snap["products"]: specs = p["specs"] ext = sb_dims(sb_spec(specs, "external dim")) if not ext or (round(ext[0]), round(ext[1])) not in EURO_FOOTPRINTS: continue internal = sb_dims(sb_spec(specs, "internal dim")) or ("", "", "") cap = sb_spec(specs, "volume", "capacity") cap_m = SB_CAP_RE.search(cap or "") blob = (p["title"] + " " + p["variant"]).lower() # Everything else in this category is an open-top euro stacking container; # Salesbridges sells no attached-lid containers. kind = "vda_klt_container" if KLT_RE.search(blob) else "euro_stacking_container" price = p["price_excl"] or "" # Two SKUs in the catalogue are listed twice under different URLs. Suffix the # repeat rather than dropping it — they are separate listings at separate # prices, and the snapshot order is fixed, so the suffix is stable. ident = p["sku"] or p["url"].rsplit("/", 1)[-1] seen_ids[ident] = seen_ids.get(ident, 0) + 1 if seen_ids[ident] > 1: ident = f"{ident}-{seen_ids[ident]}" notes = ["Stated volume is the geometric internal (top-opening) volume rather " "than a measured fill capacity, which is why the usable ratio runs " "high against the other vendors"] if "lid" in blob: notes.append("Sold with a lid; the external height includes the lid") if any(w in blob for w in ("nestable", "foldable")): notes.append("Nesting or folding crate, not a straight-walled stacker — " "its internal footprint is far under the euro norm") if "perforated" in blob or "ventilated" in blob: notes.append("Perforated/ventilated walls") if price == "": notes.append("Price on application at capture") add( listing_id=f"salesbridges-{ident}", vendor="Salesbridges", vendor_country="NL", native_unit="metric", product_name=p["title"], sku=p["sku"], url=p["url"], type=kind, external_length_cm=ext[0], external_width_cm=ext[1], external_height_cm=ext[2], internal_length_cm=internal[0], internal_width_cm=internal[1], internal_height_cm=internal[2], stated_capacity_l=float(cap_m.group(1).replace(",", ".")) if cap_m else "", price=price, currency="EUR", price_includes_vat=False, pack_quantity=1, unit_price=price, captured_date=snap["captured_utc"], notes="; ".join(notes), ) FIELDS = [ "listing_id", "vendor", "vendor_country", "product_name", "sku", "url", "type", "native_unit", "external_length_cm", "external_width_cm", "external_height_cm", "external_length_in", "external_width_in", "external_height_in", "internal_length_cm", "internal_width_cm", "internal_height_cm", "internal_length_in", "internal_width_in", "internal_height_in", "stated_capacity_l", "stated_capacity_gal", "external_volume_l", "external_volume_gal", "usable_ratio", "price", "currency", "price_includes_vat", "pack_quantity", "unit_price", "captured_date", "notes", ] with (HERE / "listings.csv").open("w", newline="", encoding="utf-8") as f: w = csv.DictWriter(f, fieldnames=FIELDS) w.writeheader() w.writerows(ROWS) print(f"{len(ROWS)} listings -> listings.csv") for v in sorted({r["vendor"] for r in ROWS}): sub = [r for r in ROWS if r["vendor"] == v] ratios = [r["usable_ratio"] for r in sub if r["usable_ratio"] != ""] span = f"{min(ratios):.0%}-{max(ratios):.0%}" if ratios else "n/a" print(f" {v:18} {len(sub):2} listings, usable ratio {span}")