fix: guard col I/J/K access for short rows in MTZ Excel
MTZ changed their Excel format — some rows have fewer than 10 columns, causing IndexError on row[9] (brand, col J). Use conditional indexing for cols I (8), J (9), K (10) so short rows parse with empty brand/type/min_box instead of crashing on startup. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
6
main.py
6
main.py
@@ -90,10 +90,10 @@ def download_and_parse():
|
||||
skipped += 1
|
||||
continue
|
||||
|
||||
brand_raw = row[9] # col J
|
||||
type_raw = row[8] if len(row) > 8 else None # col I
|
||||
brand_raw = row[9] if len(row) > 9 else None # col J
|
||||
brand = str(brand_raw) if brand_raw is not None else ""
|
||||
min_box_raw = row[10] # col K
|
||||
type_raw = row[8] # col I
|
||||
min_box_raw = row[10] if len(row) > 10 else None # col K
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user