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:
11
main.py
11
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),
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user