Skip to content

Prompting with tabular data from an event warehouse without losing rows

AI for organisersUpdated 2026-08-238 min read

In short

When prompting with tabular data, the serialisation format changes the answer. Column headers carry more weight than row order, wide tables cost far more in one format than another, and rows past the first few dozen get skipped. Aggregate in SQL and send the answer rather than the table wherever the question allows.

Ask a model which of your 80 exhibitors in hall 2 improved most on badge scans against last year, hand it the table, and it will answer. Ask it again in a different serialisation and it will answer differently. Same data, same question, same model, two answers, and no error anywhere in the pipeline to tell you one of them is wrong.

Prompting with tabular data is where a lot of event reporting quietly breaks, because the table is the natural output of every warehouse query and the natural thing to paste into a prompt. The serialisation step in between is treated as plumbing when it is a design decision with measurable consequences.

Does the serialisation format change the answer?

Sui and colleagues built a benchmark of seven tasks for this and published it at WSDM 2024 under the title "Table Meets LLM: Can Large Language Models Understand Structured Table Data?". Their finding is that performance varied with the input choices, and they name four of them: "table input format, content order, role prompting, and partition marks".

Format sitting first in that list matches what anyone gets from testing it on their own data. The same 80 rows expressed as markdown, as CSV and as JSON are three different prompts, and they differ in ways worth understanding rather than guessing at.

JSON repeats every column name on every row. An 80 row table with 8 columns carries 640 key occurrences. If the key names average four tokens each, including quotes and the colon, that is 2,560 tokens spent on nothing but repeating what the header already said once. CSV spends 8 tokens on the header and none thereafter. On a wide table the difference is the majority of the payload.

Markdown adds pipes and alignment rows and is the most readable of the three to a human, which is why teams reach for it. It sits between the other two on cost and its real advantage is that a model reading a markdown table has explicit column boundaries in every row, so a value containing a comma cannot silently shift the columns the way it can in badly quoted CSV.

JSON earns its overhead when the rows are ragged, when some records have fields others do not, or when values nest. Event aggregates are usually rectangular, so most of the time they do not.

My own default is CSV for anything over about twenty rows, markdown below that, and JSON only when the shape genuinely needs it. What matters more than the choice is that you make it once, test it against your own tables, and stop changing it, because a format change is a silent behavioural change to every prompt in the system.

Column headers do more work than anything else

A header names what a value means, and that meaning applies to every row beneath it. Get it wrong and the error propagates through the whole table.

Warehouse column names are optimised for typing rather than for reading. A table arriving from an event warehouse commonly looks like exh_id, nm, scans_d1, scans_d2, scans_d3, scans_py, sqm, rebkd. A model reading that has to guess that scans_py means the prior year rather than per year, that rebkd is a boolean about rebooking, and that sqm is square metres rather than a score.

It will guess. Sometimes correctly. The failure when it guesses wrong is a fluent paragraph describing per-year scan rates that do not exist.

Rename at serialisation time, in the code that builds the prompt rather than in the warehouse. exhibitor_id, company_name, badge_scans_day_1, badge_scans_day_2, badge_scans_day_3, badge_scans_prior_edition, stand_area_sqm, rebooked_for_next_edition. The rename costs a dictionary in one function and removes an entire class of misreading.

Two additions are worth the tokens. Put units in the header, so stand_area_sqm rather than stand_area. And where a column is a comparison, put the period in the name, because badge_scans_prior_edition is unambiguous in a way badge_scans_last_year is not when the show moved from October to March.

One thing to leave out of the header, and this catches people: do not encode a null convention in the column name. A header like badge_scans_prior_edition_0_if_none tells the model that zero and absent are the same thing, and for an exhibitor who did not attend the prior edition they are emphatically different. Send an empty field and state the convention once in the instructions, so the model can distinguish a stand that recorded no scans from a stand that did not exist. Across a portfolio the share of exhibitors with at least one genuinely absent value is large enough that this single choice changes more outputs than the format debate does.

The same discipline applies to the row identifier. Include one, even when the question does not need it, because a table without a stable key gives you no way to check an answer afterwards. If the model names an exhibitor that improved most, you want to resolve that name back to a row without a fuzzy match on a company string, and an exhibitor_id column costs a few tokens per row and makes every downstream verification trivial.

A worked example: 80 rows, two formats, two answers

Take the hall 2 table: 80 exhibitors, 8 columns, one question. Which exhibitor improved most on badge scans against the prior edition?

Serialised as CSV with renamed headers, the payload is roughly 80 rows at about 30 tokens each plus a short header, call it 2,450 tokens. Serialised as JSON with the same renamed headers, the key repetition adds around 2,900 tokens on top, so about 5,350.

Both prompts contain every row. Neither is truncated. Ask the question and you can still get two different exhibitors named, and the reason is that the model is being asked to do 80 subtractions, 80 divisions and a max, holding all of it in one pass, and it is not reliably doing that in either format.

Now compute the answer in SQL instead. One query with a computed delta and an ORDER BY returns five rows. The prompt carries 5 rows and about 160 tokens, the model does no arithmetic beyond restating what it was given, and the answer is the same every time because a database produced it.

That is a 2,290 token reduction against the CSV version, a 5,190 token reduction against the JSON version, and it converts a probabilistic ranking into a deterministic one. The format question turns out to matter most for the tables you should not have been sending.

When does the table have to go in the prompt at all?

Three cases, and it is a short list.

When the question is genuinely open and you cannot know the aggregation in advance. Somebody exploring rather than reporting.

When the model's job is to describe a shape a query cannot express, such as characterising the spread of stand sizes in a hall in prose.

When the table is small enough that sending it is cheaper than building a query, which for a five row summary block is usually true.

Everything else should arrive pre-aggregated. Rankings, totals, top-n, growth rates, shares of a whole: all of them are one line of SQL and none of them are things a language model does reliably at scale. Q19 covers why the arithmetic itself goes wrong, and Q31 covers the aggregate-shaped alternative in more depth. The decision of which model gets the resulting narrative is a separate bake-off at Q27.

Long tables lose the middle

There is a second effect layered on top of format, and it is well documented.

Liu and colleagues published "Lost in the Middle: How Language Models Use Long Contexts" as a preprint in 2023 and in Transactions of the Association for Computational Linguistics, volume 12, in 2024. Their central result is that "performance is often highest when relevant information occurs at the beginning or end of the input context, and significantly degrades when models must access relevant information in the middle of long contexts".

For a table that is a specific and unpleasant property. Row 3 and row 78 of an 80 row table are read more reliably than row 40, and nothing about the output signals which rows were read well. If your table is sorted alphabetically by company name, the exhibitors most likely to be skimmed are an arbitrary set determined by the alphabet.

Sorting deliberately is a partial mitigation. If the question concerns the largest movers, sort by the delta so the interesting rows sit at the top. If it concerns the whole hall, accept that a long table is being sampled and go back to aggregating in SQL. Where each fact should sit inside the context more generally is the ordering question that Q30 takes on, and it applies to the prose around the table as much as to the rows.

Where this stops

Every recommendation here is measurable on your own data and none of them is universal. Format effects differ by model, and a compact model may be far more sensitive to serialisation than a larger one, so a format tested on one candidate does not transfer when you switch. That is one more reason to keep the format under version control and rerun the eval when the model changes, which is part of the same discipline as routing tasks by size in Q28.

The harder limit is that aggregating in SQL only works when you know the question. A question-and-answer surface over a warehouse does not, by definition, and the honest engineering answer there is to generate a query rather than to send a table, which moves the problem into query correctness and out of serialisation. That is a real move rather than a dodge, and it is a different post's subject.

The audit worth running this week takes twenty minutes and needs no model at all. Take one table your pipeline currently serialises into a prompt, print its column headers on a sheet of paper, and ask a colleague on the commercial team to write down what each one means. Every header they get wrong or cannot answer is a header the model is also guessing at, and the fix is a rename dictionary in the serialisation function rather than a change to anything downstream. The pillar covers the surrounding decisions on AI over event data.

Questions people ask about prompting with tabular data

Which format should you use for a table in a prompt?
For wide tables, a delimited format such as CSV, because JSON repeats every column name on every row and that overhead grows with row count. For small tables where readability matters, markdown is fine. The important discipline is picking one, testing it on your own data, and keeping it the same across every call.
Do column headers matter more than row order?
Yes. A header names what a value means and applies to every row beneath it, so an ambiguous header propagates error through the whole table. Row order matters mainly through position effects in long inputs. Rename scans_d1 to badge_scans_day_1 before you spend any time reordering rows.
How many rows can you safely put in a prompt?
Fewer than people assume, and the failure is silent. A model asked to rank or total a long table returns a plausible answer built from part of it. Compute rankings and totals in SQL, send the handful of rows that answer the question, and keep the raw table out of the prompt entirely.

Related reading

All ai for organisers articles