29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
"""Quick diagnostic – prints every sheet name, its headers, and 3 sample rows."""
|
|||
|
|
from pathlib import Path
|
|||
|
|
import openpyxl
|
|||
|
|
|
|||
|
|
path = Path("OCTO") / "seout.xlsx"
|
|||
|
|
if not path.exists():
|
|||
|
|
print(f"NOT FOUND: {path}")
|
|||
|
|
raise SystemExit(1)
|
|||
|
|
|
|||
|
|
wb = openpyxl.load_workbook(path, data_only=True, read_only=True)
|
|||
|
|
for sheet in wb.sheetnames:
|
|||
|
|
ws = wb[sheet]
|
|||
|
|
rows = list(ws.iter_rows(values_only=True))
|
|||
|
|
print(f"\n=== Sheet: {sheet!r} ({len(rows)} rows) ===")
|
|||
|
|
# Print first 15 rows so we can see past the metadata
|
|||
|
|
for i, row in enumerate(rows[:15]):
|
|||
|
|
vals = [v for v in row if v is not None]
|
|||
|
|
if vals:
|
|||
|
|
print(f" row {i+1}: {list(row)}")
|
|||
|
|
# Also find any row that looks like a header (contains text with "part" or "mfg" or "price")
|
|||
|
|
print("\n --- Searching for header row ---")
|
|||
|
|
for i, row in enumerate(rows):
|
|||
|
|
row_str = [str(v).lower() for v in row if v is not None]
|
|||
|
|
if any("part" in v or "mfg" in v or "price" in v or "avg" in v for v in row_str):
|
|||
|
|
print(f" row {i+1}: {list(row)}")
|
|||
|
|
break
|
|||
|
|
wb.close()
|