From 2dcdb00a219ade92abca01714fea46dc6a2cd04e Mon Sep 17 00:00:00 2001 From: Malin Date: Mon, 23 Mar 2026 12:30:17 +0100 Subject: [PATCH] feat: skip starred products; add type field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index dba24bb..63d13f3 100644 --- a/main.py +++ b/main.py @@ -84,10 +84,18 @@ def download_and_parse(): skipped += 1 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 = str(brand_raw) if brand_raw is not None else "" 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( { "item_code": safe_int(row[1], 0), @@ -96,6 +104,7 @@ def download_and_parse(): "price_usd": safe_float(row[4], 0.0), "stock": safe_int(row[5], 0), "brand": brand, + "type": product_type, "min_box_qty": safe_int(min_box_raw, 1), } )