shawn af566bc368 Add suite/room/trailer extraction + ID-based class correction
Parser enhancements:
- Add SUITE_PATTERNS: extract Suite, Ste, STE (case-insensitive)
- Add ROOM_PATTERNS: extract Room, RM, Mailroom, Showroom, etc.
- Add TRAILER_PATTERNS: extract Trailer, TRLR, MASH, Safari, etc.
- Add _extract_suite(), _extract_room(), _extract_trailer() functions
- Update _parse_pattern_a() to extract and strip new fields
- Update parse_place() result dict to include suite/room/trailer
- Add correct_class_by_machine_id() post-processing:
  - Bev model in Bev ID range with Snack class → fix to Bev
  - Unknown class in 9x range → set to Bev
  - Unknown class in 6x-7x range → set to Snack
- Update parse_excel() to include new fields and apply correction

DB writer:
- Add suite, room, trailer to ALL_COLUMNS and COLUMN_TYPES
- Add ALTER TABLE migration for existing databases
2026-05-24 23:22:35 -04:00

🌱 Canteen Seed Data Import Tool

Standalone seed data import tool for the Canteen Asset Tracker. Conceptualizes the import pipeline before integration into the admin panel.

Purpose

Import Cantaloupe seed data (CSV export) into the canteen assets database with:

  • Header Mapping — Raw Excel headers → CSV headers → DB column names
  • Location Extraction — Parse Customer & Place columns into structured fields
  • GPS Derivation — Handle multi-floor GPS offsets
  • Serial Validation — OCR corrections, unknown machine identification
  • Type/Class/Make/Model Normalization — Consolidate to Class, Make, Model
  • Pricing Status Decoding — Remote pricing status meanings
  • Telemetry Decoding — Card reader brand/type from telemetry IDs
  • Alert Interpretation — Alert code meanings
  • Sales Priority Scoring — Low/mid/high business value
  • Backup & Restore — Preserve existing GPS + check-in data
  • Validation Reports — Detailed import summary

Data Files

seed-data/
├── header_modified.csv    # Header mapping: raw Excel → CSV → DB
├── import_seed.csv        # Seed data (vending machine export)
└── reference_handbook.md  # Extraction rules & reference docs

Usage

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

python main.py seed-data/import_seed.csv --db /path/to/assets.db [--dry-run]

Web UX

Standalone web interface for uploading, previewing, and importing Cantaloupe data:

cd ~/projects/canteen-seed-import
source .venv/bin/activate
pip install -r requirements.txt  # ensure web deps are installed

python -m web_ux.main --port 8089

Then open http://localhost:8089

Features:

  • 📊 Dashboard — DB stats, class/make breakdown, GPS coverage
  • 📤 Import — Drag-and-drop Excel upload, preview parsed data, choose seed/update mode, run import with automatic backup
  • 💾 Backup — Create/manage/compare/restore GPS+photo backups
  • 📋 Report — View the latest validation report
  • ⚙️ Config — View header mappings and handbook reference

API Endpoints

Method Path Description
GET /api/status DB stats and health
GET /api/config Header mappings + handbook info
POST /api/upload Upload Excel file, returns preview token
GET /api/preview/{token} Get paginated preview data
POST /api/import Run import (seed/update)
GET /api/report Latest validation report
POST /api/backup Create database backup
GET /api/backups List existing backups
POST /api/backup/compare Compare backup to current DB
POST /api/backup/restore Restore preserved fields from backup

Integration

Once validated, this tool will be integrated into the Canteen Admin Server.

Database Schema

Shares the same assets.db schema as the Canteen Asset Tracker:

  • assets table with columns: machine_id, serial_number, name, make, model, address, building_name, building_number, floor, room, trailer_number, latitude, longitude, company, location_area, place, category, status, priority, pricing_status, card_reader_brand, card_reader_model, dex_report_date, install_date, deployed, pulled_date, disney_park, is_disney, etc.
  • checkins table for GPS check-in records
  • See main project for full schema.

Priority

This tool is a conceptual prototype. Once the pipeline is stable, the logic will be ported to the admin panel as a feature.

S
Description
🌱 Seed data import tool for Canteen Asset Tracker
Readme 390 KiB
Languages
Python 73.1%
HTML 26.5%
Shell 0.4%