leondavi's picture
Public mirror of the Cells demo puller CSV (synthetic, CC0)
a61cfbe verified
Raw History Blame Contribute Delete
3.14 kB
"""Generate the synthetic CSVs in this dataset. Every value is invented.
Brands, model names, prices and dates are made up by a seeded random
generator; nothing is real, scraped or copied. Re-running this script
reproduces the files byte for byte:
python make_data.py
"""
import csv
import random
from datetime import date, timedelta
SEED = 20260927
BRANDS = ["Arvelo", "Brindlecore", "Corvane", "Duskmere", "Elmstead", "Fennix", "Glimmerly", "Halvorn"]
CATEGORIES = {
# category: (price range in USD, model-name stems)
"cpu": ((79, 899), ["Vex", "Torrent", "Kestrel"]),
"gpu": ((149, 1899), ["Auralis", "Nimbus", "Ember"]),
"ssd": ((39, 549), ["Drift", "Slate", "Quill"]),
"ram": ((29, 429), ["Pulse", "Lattice", "Ripple"]),
"motherboard": ((89, 699), ["Keystone", "Harbor", "Trellis"]),
"psu": ((49, 329), ["Volta", "Current", "Bastion"]),
"monitor": ((119, 1299), ["Vista", "Prism", "Horizon"]),
}
STORES = ["north-depot", "harbor-outlet", "ridge-market", "online"]
def hardware_prices(rng: random.Random) -> list[dict]:
rows = []
seen = set()
while len(rows) < 200:
brand = rng.choice(BRANDS)
category = rng.choice(sorted(CATEGORIES))
(lo, hi), stems = CATEGORIES[category]
model = f"{rng.choice(stems)} {rng.choice('ABCDEFGHJKLMNPRSTXZ')}{rng.randint(1, 9)}{rng.choice(['', '0', '00', '50'])}"
if (brand, model) in seen:
continue
seen.add((brand, model))
rows.append(
{
"id": len(rows) + 1,
"brand": brand,
"model": model,
"category": category,
"price_usd": f"{rng.uniform(lo, hi):.2f}",
"release_year": rng.randint(2019, 2026),
}
)
return rows
def price_observations(rng: random.Random, products: list[dict]) -> list[dict]:
"""A second, long-shaped table: price checks of some products over time."""
rows = []
start = date(2026, 1, 5)
for n in range(120):
p = rng.choice(products)
base = float(p["price_usd"])
observed = start + timedelta(days=rng.randint(0, 250))
in_stock = rng.random() > 0.2
rows.append(
{
"observation_id": f"obs-{n + 1:04d}",
"product_id": p["id"],
"store": rng.choice(STORES),
"observed_on": observed.isoformat(),
"price_usd": f"{base * rng.uniform(0.85, 1.12):.2f}" if in_stock else "",
"in_stock": "true" if in_stock else "false",
}
)
rows.sort(key=lambda r: (r["observed_on"], r["observation_id"]))
return rows
def write(path: str, rows: list[dict]) -> None:
with open(path, "w", newline="", encoding="utf-8") as f:
w = csv.DictWriter(f, fieldnames=list(rows[0]), lineterminator="\n")
w.writeheader()
w.writerows(rows)
if __name__ == "__main__":
rng = random.Random(SEED)
products = hardware_prices(rng)
write("hardware_prices.csv", products)
write("price_observations.csv", price_observations(rng, products))