Five Vendor CSV Exports, One Dashboard for Budget Leaks

Five exports, five sets of column names, three currencies, and a day of manual reconciliation that still leaves discrepancies. That is the usual monthly ritual. Here is what you get at the end of this build: one Python project that ingests all five files, normalizes them into a single schema, and renders a dashboard where a losing campaign or category is visible in the first ten seconds — not after a pivot-table marathon.

You will see it works when the dashboard's total spend for a month matches the control sum printed in each ad cabinet to the cent, and when a duplicate order that appears twice in the marketplace export shows up once in the merged table.

What the project actually is, in scope terms

It is not a chatbot and not a BI platform. It is one script, a small config folder, and a local dashboard. Three axes define the scope: More on the topic: “One Dashboard from 1C and CSV, Built in Python”.

  • Ingestion — five files per month, each with its own column names and currency.
  • Normalization — dates to ISO, currencies to one base, campaign and category names to a canonical form, duplicate orders dropped.
  • Reconciliation and view — totals checked against control sums, then charts that flag negative-margin campaigns and categories.

If you only need the reconciliation number (no charts), stop after step 4. If you need roles, sharing, and monthly automation for a team, that is a different, larger product — see the cost section.

Step 1. Collect the five exports and their control sums — human, no AI

The single most important thing you do before writing any code: for every file, write down the control sum the vendor portal itself reports. In an ad cabinet that is the spend figure for a chosen date range. In a marketplace it is the settlement report total. In a bank statement it is the closing balance movement.

You need:

  • Export rights on each portal (usually the account owner or an admin role — a read-only analyst account often cannot export).
  • The same date range on all five exports, and the same timezone setting. A cabinet set to UTC and a marketplace set to local time will shift a day of orders across the month boundary and produce a phantom discrepancy.
  • The files saved under a predictable name, e.g. 2026-11_ads.csv, 2026-11_marketplace.xlsx, 2026-11_bank.csv.

Where access is impossible: some bank portals do not expose a CSV export at all, only a PDF statement or a web view. In that case you either export manually each month (fine for a small shop) or ask the bank for API access, which usually requires a business account tier. Do not build a PDF scraper as your first move — check the portal's own export options and the bank's developer documentation first.

Step 2. One canonical schema, decided by a human

The AI can propose a schema, but you decide it, because it encodes your business rules. A workable minimum:

Field Type Note
date date (ISO) normalized from all formats
source text ads / marketplace / bank
campaign text canonical name
category text canonical name, nullable
spend decimal in base currency
revenue decimal in base currency
currency_original text kept for audit
order_id text nullable, used for dedup

Two decisions you make here and the AI cannot: which currency is the base (pick the one your bank account settles in), and what the dedup key is for orders. For a marketplace, order_id plus source is usually enough. If the same order can appear in both a marketplace export and a bank payment line, you need a rule for which one wins — normally the marketplace, because the bank line is the money movement, not the order.

Step 3. The normalizer script — AI writes, you review

This is where an AI agent earns its keep. Give it one sample file per vendor and the schema above. It writes a parser per export: column mapping, date parsing, currency conversion, name canonicalization.

A minimal, runnable core looks like this. Install exactly what the code uses:

pip install pandas==2.2.3 openpyxl==3.1.5
import pandas as pd

BASE = "USD"
RATES = {"USD": 1.0, "EUR": 1.08, "GBP": 1.27}  # your monthly rates, human-checked

COLUMN_MAP = {
    "ads": {"Day": "date", "Campaign Name": "campaign", "Cost": "spend", "Currency": "currency_original"},
    "marketplace": {"Order Date": "date", "Item": "category", "Order ID": "order_id", "Payout": "revenue"},
}

def normalize(df: pd.DataFrame, source: str) -> pd.DataFrame:
    df = df.rename(columns=COLUMN_MAP[source])
    df["date"] = pd.to_datetime(df["date"], dayfirst=False, errors="coerce").dt.date
    cur = df.get("currency_original", pd.Series([BASE] * len(df)))
    rate = cur.map(RATES).fillna(1.0)
    for col in ("spend", "revenue"):
        if col in df:
            df[col] = pd.to_numeric(df[col], errors="coerce").fillna(0) * rate
    df["source"] = source
    return df

What the AI does well: writes the per-vendor parser, handles the column names that differ between months, converts 1,234.50 and 1 234,50 into a number. What you check by hand: the COLUMN_MAP for each file against the real header row, and the RATES table against your actual monthly rates — the AI will happily invent a rate if you do not supply one.

Two things that break parsers on real data:

  • Encoding. A marketplace export in cp1251 or with a BOM will throw a UnicodeDecodeError. Open the file in a text editor, check the encoding, pass it explicitly to read_csv(..., encoding="...").
  • Header rows above the data. Many portals put a title row, a date range, then the header. Use skiprows= and verify the column count after loading.

Step 4. Dedup and reconciliation — human owns the rule

Dedup is a business decision, not a technical one. The AI can implement df.drop_duplicates(subset=["order_id", "source"]), but you decide whether a refunded order counts once or twice, and whether a partially settled order should be split.

Reconciliation is the check that makes the whole project trustworthy. After merging, sum spend per source and per month, and compare against the control sums from step 1:

for source, expected in control_sums.items():
    got = merged.loc[merged["source"] == source, "spend"].sum()
    print(source, round(got, 2), expected, round(got - expected, 2))

A difference under a cent per line is rounding noise. A difference of a whole order or a day means a timezone shift or a dropped row. A difference of exactly one campaign's budget means that campaign's currency was not converted.

The check that saves the project Reconcile before you build any chart. A dashboard built on unreconciled data looks confident and is wrong — and you will only find out when someone asks why the total does not match the cabinet.

Step 5. The dashboard — where the leak becomes visible

The value of this screen is one question: which campaign or category is losing money. Two views answer it:

  • Margin by campaign — revenue minus spend, sorted ascending. The bottom of the list is the leak.
  • Spend vs revenue over time — a line per campaign, so you see when a campaign started burning budget without a matching revenue trend.

The AI can generate the plotting code (matplotlib, plotly, or a small Streamlit app). You check one thing by hand: that the numbers on the chart match the reconciled table for the same filter. If they do not, the chart is filtering on a different date range than the table.

Example: One campaign at the bottom of the margin list is the leak-310-127.555237.5420420 USD margin420Campaign A180 USD margin180Campaign B-60 USD margin-60Campaign C-310 USD margin-310Campaign D
Example: One campaign at the bottom of the margin list is the leak

Where it breaks on real data

Three failures are common enough to plan for.

  1. Lost duplicates and double-counted refunds. A refund appears in the marketplace export and again as a bank reversal. If your dedup key ignores refunds, you count the loss twice and blame the wrong campaign. Fix: add a transaction_type field and reconcile refunds separately from orders.
  2. Currency drift. You hardcode a rate in January and forget it in March. Every converted figure is then silently wrong by the rate movement. Fix: keep the rate table in a separate file with a date, and make the script print a warning when a month has no rate.
  3. A vendor changes its column names. A portal renames Cost to Spend and the parser silently maps nothing, producing a month of zeros. Fix: after loading, assert that every expected column exists and that spend is not all-zero — fail loudly instead of rendering an empty chart.

How to verify it by hand

Run these four checks before trusting the dashboard:

Check What you do Success sign
Control sum per source Compare script total to cabinet total Difference under 0.01
Duplicate order Find a known duplicate in the raw file It appears once in merged data
Currency conversion Pick one EUR line, recompute by hand Matches script to the cent
Chart vs table Filter one campaign on both Same revenue and spend

If all four pass for one month, run the same month again with a different file order — the result must not change.

What it costs in time and money

For a single shop with five steady exports, expect roughly a day to a day and a half of build time for a person working with an AI agent: half a day on parsers and schema, half on reconciliation, the rest on charts. The recurring cost is small — a few minutes a month to export the files and check the control sums.

The time depends on three things: how many of the five exports have stable column names, whether any portal has no CSV at all (a PDF-only bank statement can double the build), and how many currencies you actually settle in. If you need this as a shared product with roles, scheduled runs, and alerts when a campaign goes negative, that is a multi-week build, not a script — and that is the point where handing it over turnkey makes sense. asibiont.com takes such projects on turnkey: the developer names the price and you top up the balance as work proceeds — see the tiers at https://asibiont.com/en/subscription-tiers.

The rule that keeps it honest

The dashboard is only as good as the reconciliation step. Build the normalizer, prove it against the cabinet's own totals, and only then let the charts speak. A month where the totals match is a month you can act on — and a campaign sitting at the bottom of the margin list is a decision you can make the same afternoon. If you want the same reconciliation discipline applied to a different stack, the developer's turnkey option at https://asibiont.com/en/subscription-tiers is the same path with the build handled for you. More on the topic: “BI Analytics and Dashboards: What to Know Before You Start — Requirements, Pitfalls, and Real Practice”.

← All posts

Ask AI about this article

Ask a question about this article — ASI Biont will answer based on its text.