Topic 5 of 5 · 4 min read
Reusable templates for recurring files
Goal: Write a reusable extraction template with a fixed column schema, two examples and rules for missing values.
If the same kind of file arrives every week, write the extraction prompt once as a template with a fixed schema, two examples and rules for missing values, and then reuse it unchanged. A saved template gives the same columns every time, and it makes problems easy to see.
Check yourself · 1 of 3
Why does a saved template give better weekly results than a fresh prompt each time?
Why it matters
An improvised prompt gives a slightly different table each week. The columns change order, a name changes from Amount to Total, and a month of reports no longer lines up. You also lose the lessons from the last bad run. A template fixes the format, and the same checks can follow it every time.
The parts of a template
- Purpose and source. One line: "You extract rows from the weekly supplier statement from Northwind Foods."
- Column schema. The exact column names, their order, their type and the allowed values. For example: Date (YYYY-MM-DD), Invoice no. (text), Amount (number, no currency sign), Status (Paid, Open or Disputed).
- Missing-value rules. What to write when something is absent or unreadable, and a ban on guessing.
- Two examples. One normal row from a real past file with the correct output, and one odd case, such as a credit note with a negative amount, with the correct output. Examples show format better than any description.
- Output format. CSV only, no comments, a header row first.
- Checks to run afterwards. Row count, total, and a sample, written on the template so nobody skips them.
If you use a model through an API, many providers offer structured output: you give a schema and the answer must fit it. ChatGPT, Claude and Gemini projects or custom assistants can store the template text, so you do not paste it each week.
Before and after
Before: Each Monday, someone types "put this statement in a table" and gets whatever the model feels like.
After: A saved template lists six columns in a fixed order, says "if Status is not shown, write MISSING", includes the credit note example and ends with "Return CSV only." The table is the same every Monday, so last week's can be compared with this week's.
What goes wrong
- Never updating the template. The supplier adds a column and the template quietly drops it.
- Examples with real personal data. Use fake names or remove them.
- Too many examples. Ten examples make the model copy details such as an old date. Two good ones are enough.
- No version. Without a date and a change note, nobody knows which template made which table.
- Skipping the checks because the template worked last time.
Examples
The credit note example
A weekly statement sometimes lists credit notes with a minus sign. The template includes one such row and the expected output: Amount -120.00, Status Paid. Since the example is in the template, the model stops dropping the minus sign, and the weekly total matches the printed total again.
The silent new column
The supplier adds a Discount column in March. The template has no such column, so the discount is ignored and the total no longer matches. The total check reveals it, and the fix is a new template version with a Discount column and a change note.
Key points
- A template fixes the column names, order, types and allowed values so every week's table has the same shape.
- State the missing-value rule in the template; do not rely on the model to choose a safe default.
- Two examples, one normal and one unusual, show the format better than a long description.
- Structured output or a saved assistant removes the copy-paste step and the drift that comes with it.
- Version the template, and put the validation checks in it so they are run every time.
Common mistakes
- Retyping the prompt from memory each week.
- Using ten examples, so the model copies their details.
- Putting real customer data into the examples.
- Not versioning the template, so nobody knows why two tables differ.
Check yourself · 2 of 3
How many examples should an extraction template usually include?
Check yourself · 3 of 3
The supplier adds a Discount column and your template has no field for it. What is the right response?
Practice items, not counted towards your mastery.
Start here
- OpenRefine (opens in a new tab)ToolFree
A free desktop tool for clustering name variants and fixing a column in bulk, with every step recorded.
- Tabula: extract tables from PDFs (opens in a new tab)ToolFree
Free tool that pulls tables out of text-based PDFs without a language model, a useful cross-check.
- Vision (Claude docs) (opens in a new tab)DocsFree
What image and PDF reading can and cannot do, including limits on small text and tables.
More for this topic
- Structured outputs (Claude docs) (opens in a new tab)DocsFree
How to make a model return data that fits a fixed schema.
- Structured model outputs (OpenAI API docs) (opens in a new tab)DocsFree
The same idea from another vendor: a JSON schema the answer must follow, including optional fields.