{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Read the Vynn free export sample\n",
    "Download observations.csv alongside this notebook from https://vynn.ai/data.\n",
    "42 rows from a real Ontario export prepared October 19, 2026, in that export's original 24 columns. New exports add UPC Match Status; see https://vynn.ai/data#export-columns.\n",
    "We count rows, promotions and filled unit prices for each store. Blank cells stay blank.\n",
    "Read the accompanying README.md for selection, field definitions, and terms."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"Reproduce the /data sample readout. Python standard library only.\"\"\"\n",
    "import csv\n",
    "from collections import defaultdict\n",
    "from pathlib import Path\n",
    "import sys\n",
    "\n",
    "\n",
    "def summarise(path):\n",
    "    groups = defaultdict(list)\n",
    "    with Path(path).open(encoding='utf-8', newline='') as source:\n",
    "        for row in csv.DictReader(source):\n",
    "            groups[(row['Banner'], row['Store ID'], row['Store City'])].append(row)\n",
    "    for (banner, store, city), rows in sorted(groups.items()):\n",
    "        promo = sum(row['On Promotion'] == 'true' for row in rows)\n",
    "        unit = sum(row['Unit Price'] != '' for row in rows)\n",
    "        yield (banner, store, city, len(rows), promo, unit)\n",
    "\n",
    "\n",
    "for row in summarise('observations.csv'):\n",
    "    print(row)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
