# Exporting Merged Data for ChatGPT Code Interpreter Analysis: The Bambu Lab Filament Database Guide

> Export merged data for ChatGPT Code Interpreter analysis by downloading Parquet shards and compiling with the reconstruct_db.py script. Analyze Bambu Lab filament data now.

- Repository: [Nelson Chen/bbl-tracker-public-db](https://github.com/nelsonjchen/bbl-tracker-public-db)
- Tags: how-to-guide
- Published: 2026-03-08

---

**Exporting merged data for ChatGPT Code Interpreter analysis requires downloading the last 30 days of Parquet shards from the public Cloudflare R2 bucket and compiling them into a single DuckDB file using the provided [`reconstruct_db.py`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/reconstruct_db.py) script.**

The **Bambu Lab Store Filament Tracker** maintains an open dataset of real-time filament stock levels from the Bambu Lab storefront. Hosted in the `nelsonjchen/bbl-tracker-public-db` repository, this project provides Python utilities that transform scattered time-series Parquet files into a unified local database optimized for AI analysis. Whether you are tracking availability bottlenecks or training predictive models, exporting merged data for ChatGPT Code Interpreter analysis begins with understanding the underlying shard architecture.

## Understanding the Database Architecture

The dataset is organized as a collection of immutable Parquet shards updated every six hours, enabling efficient time-series analysis without downloading redundant historical data.

### Parquet Shards on Cloudflare R2

Data snapshots are serialized to columnar Parquet format and hosted on **Cloudflare R2** at `https://db-public.bbltracker.com/`. Each file follows the naming convention `YYYY-MM-DD-HHMM.parquet` (for example, `2026-02-16-0000.parquet`), representing a specific UTC timestamp. According to the repository source code, every shard contains standardized columns including `timestamp`, `product_name`, `variant_name`, `stock`, `region`, `max_quantity`, and `is_flash_sale`.

### The Manifest Index

Rather than scraping directory listings, the system maintains a [`manifest.json`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/manifest.json) at the root of the bucket. This JSON file maps each filename to metadata including row counts, enabling programmatic discovery of available shards. Both [`script.py`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/script.py) and [`reconstruct_db.py`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/reconstruct_db.py) begin execution by fetching this manifest via `urllib.request.urlopen` to determine which files to process.

## Quick Start: Analyzing Recent Availability

For immediate insights without exporting the full history, the repository provides [`script.py`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/script.py). This lightweight utility fetches the manifest, selects the four most recent shards (covering approximately the last 24 hours), and executes a DuckDB query to calculate per-item availability percentages.

Run the availability bottleneck report:

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
uv pip install duckdb pandas
uv run script.py

```

The script outputs a formatted table identifying which SKUs have the lowest `availability_pct`, highlighting products likely to stall multi-item purchases.

## Exporting Merged Data for ChatGPT Code Interpreter Analysis

To perform deep historical analysis or natural language querying via AI code interpreters, you must consolidate distributed shards into a single local database file.

### Step 1: Execute the Reconstruction Script

The [`reconstruct_db.py`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/reconstruct_db.py) file automates the download and merge process. It filters the manifest for shards from the last 30 days, streams the Parquet files from Cloudflare R2, and materializes them into a local DuckDB instance.

```bash
uv run reconstruct_db.py

```

Expected output:

```

--- Bambu Stock DB Reconstructor ---
Fetching manifest...
Found 120 total shards.
Filtering for past 30 days (>= 2026-02-06)... 84 files selected.
Creating bambu_stock.duckdb...
Downloading and merging data...
Success! Imported 1,234,567 rows into 'bambu_stock.duckdb'.

```

### Step 2: Verify the Local Schema

The resulting `bambu_stock.duckdb` file contains a single table named `stock_history` with the following structure:

- **timestamp**: ISO-8601 snapshot time
- **product_name**: Base product identifier (e.g., "PLA Matte")
- **variant_name**: Specific configuration (e.g., "White - 1kg")
- **stock**: Current inventory count at snapshot time
- **region**: Geographic storefront region (e.g., "us", "eu")
- **max_quantity**: Purchase limit caps during flash sales
- **is_flash_sale**: Boolean flag indicating promotional periods

### Step 3: Upload to ChatGPT Code Interpreter

Once generated, upload `bambu_stock.duckdb` directly to the ChatGPT Code Interpreter environment. The compact columnar format typically results in file sizes under 50MB for 30 days of data, staying well within upload limits while preserving millions of rows.

## Query Patterns for AI Analysis

After exporting merged data for ChatGPT Code Interpreter analysis, you can prompt the AI with specific analytical requests without writing SQL manually:

- *"When is Black PETG usually in stock?"* — The AI can query `stock_history` to calculate hourly availability windows by `product_name` and `region`.
- *"Plot hourly availability for PLA Matte White over the last week."* — The system generates time-series visualizations using the `timestamp` and `stock` columns.
- *"Identify products with the most volatile inventory in the US region."* — The AI computes coefficient of variation across time windows using `stock` deltas.

## Alternative: Direct Remote Querying Without Export

If you prefer not to download files locally, DuckDB supports reading remote Parquet URLs directly. This method eliminates the need for [`reconstruct_db.py`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/reconstruct_db.py) but requires stable internet connectivity during analysis.

```python
import duckdb

urls = [
    f"https://db-public.bbltracker.com/2026-02-16-{h:02d}00.parquet"
    for h in (0, 6, 12, 18)
]

df = duckdb.read_parquet(urls).filter("region = 'us'") \
    .groupby("product_name, variant_name") \
    .agg(
        total="count(*)",
        in_stock="sum(CASE WHEN stock > 0 THEN 1 ELSE 0 END)"
    ) \
    .select(
        "product_name || ' - ' || variant_name AS full_name",
        "ROUND(in_stock::FLOAT/total*100,1) AS availability_pct"
    ) \
    .order("availability_pct") \
    .fetchdf()

```

This approach performs on-the-fly bottleneck detection identical to [`script.py`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/script.py) while keeping storage requirements minimal.

## Summary

- **The Bambu Lab dataset** resides as Parquet shards on Cloudflare R2, indexed by [`manifest.json`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/manifest.json).
- **[`reconstruct_db.py`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/reconstruct_db.py)** generates `bambu_stock.duckdb` containing 30 days of merged `stock_history` data.
- **Exporting merged data for ChatGPT Code Interpreter analysis** enables natural language querying of filament availability trends across millions of rows.
- **Direct remote querying** via DuckDB's `read_parquet` function offers a lightweight alternative for ephemeral analysis without local storage.
- **Columnar storage** ensures that both export and query operations remain fast even on modest hardware.

## Frequently Asked Questions

### How large is the exported DuckDB file after 30 days of data?

The resulting `bambu_stock.duckdb` file typically ranges between 20MB and 60MB depending on market volatility and the number of active SKUs. Columnar compression in DuckDB keeps the footprint small despite containing over one million historical rows.

### How often is the public database updated?

New Parquet shards are published every six hours (UTC). The [`manifest.json`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/manifest.json) updates simultaneously, meaning both [`script.py`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/script.py) and [`reconstruct_db.py`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/reconstruct_db.py) always access the most recent available snapshots without manual intervention.

### Can I analyze regions other than the US storefront?

Yes. The `region` column contains values such as "us", "eu", and "global". Both [`script.py`](https://github.com/nelsonjchen/bbl-tracker-public-db/blob/main/script.py) and custom DuckDB queries can filter by this column to analyze specific geographic markets or compare availability patterns across regions.

### What license covers this dataset?

The repository and its data are released under the **Open Data Commons Open Database License (ODbL)**. You are free to share, create, and adapt the database provided you attribute the source, share-alike any derivatives, and keep the data open.