feat: skip starred products; add type field

- Skip products where description contains '*' after the (NNNNN) code
  (e.g. "France*") — MTZ's exclusion marker
- Add 'type' field (col G, numeric prefix stripped) to API response

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Malin
2026-03-23 12:30:17 +01:00
parent 0b4aa0181b
commit 2dcdb00a21

11
main.py
View File

@@ -84,10 +84,18 @@ def download_and_parse():
skipped += 1 skipped += 1
continue continue
# Skip products marked with * after the country (e.g. "France*") — MTZ exclusion flag
raw_desc = str(row[2] or "")
if re.search(r'\(\d+\).*\*', raw_desc):
skipped += 1
continue
brand_raw = row[9] # col J brand_raw = row[9] # col J
brand = str(brand_raw) if brand_raw is not None else "" brand = str(brand_raw) if brand_raw is not None else ""
min_box_raw = row[10] # col K min_box_raw = row[10] # col K
description = re.sub(r'\s*\(\d+\).*$', '', str(row[2] or "")).strip() type_raw = row[6] # col G
product_type = re.sub(r'^\d+\.', '', str(type_raw)).strip() if type_raw is not None else ""
description = re.sub(r'\s*\(\d+\).*$', '', raw_desc).strip()
parsed.append( parsed.append(
{ {
"item_code": safe_int(row[1], 0), "item_code": safe_int(row[1], 0),
@@ -96,6 +104,7 @@ def download_and_parse():
"price_usd": safe_float(row[4], 0.0), "price_usd": safe_float(row[4], 0.0),
"stock": safe_int(row[5], 0), "stock": safe_int(row[5], 0),
"brand": brand, "brand": brand,
"type": product_type,
"min_box_qty": safe_int(min_box_raw, 1), "min_box_qty": safe_int(min_box_raw, 1),
} }
) )