Back to Guides

Spreadsheets and tabular data with agents

Turn spreadsheets into clean tables and records that an AI agent can analyse, check and keep up to date.

Many researchers find themselves with data in spreadsheets that they want to analyse, reuse and share, and they want an AI agent such as Claude Code or Codex to help with the work.

This guide is one of a series:

Where the data starts: an Excel workbook

Research data often lives in Excel workbooks. A typical workbook has several sheets. The headers use merged cells. Colours mean something. There are notes in cells, totals mixed in with the data, and sometimes several tables on one sheet.

Agents can read .xlsx files, but analysis and reuse go better on clean tables. The rest of this guide is about getting from the workbook to clean tables and keeping them clean.

Start with a conversation about storage and updates

Before asking an agent to convert anything, start a conversation about its understanding of the structure that helps you both understand what's in the data set and how to work with it:

  • what is the data;
  • are there any inconsistencies or duplications in the data;
  • what questions you want the data to answer.

Then ask the agent to propose how to store the data. These are the usual options.

  • CSV, one file per table, for data that is inherently tabular: small, mostly numbers, very short text. Simple, and diffable in Git: Git shows exactly which lines changed between two versions of the file.
  • Markdown files with YAML metadata, one file per item, for substantive records such as detailed survey responses or interview notes.
  • JSON for tables whose rows are structured items with important content of their own, such as the word table of a grammar book, where every value should carry its label. Rarely for records with long text: those are easier to read as Markdown files with YAML metadata.
  • SQLite or DuckDB as an index built from the files, for many related tables, or for millions of rows.
  • Parquet for large numerical data. Parquet is a compact file format for large tables.

Then decide the update path. Will new rows be appended to a CSV file? Will someone keep working in Excel, with the tables re-exported from the workbook each time? Will new records come in through a form? The conversion script and the checks described below depend on the answer.

Files are the record, databases are the index

In my talk on the future of data at the Oxford Data Meetup in November 2026, many people found this analogy useful. Before databases, you put a book on the shelf next to the other books, or a box in the archive next to the other boxes, and people's understanding did the rest. The file system with folders and subfolders replicates the old approach. But keeping thousands of files in folders does not scale. They become hard to search and make connections between.

That's why databases were developed to both store and assist discovery. But as databases took over storage of more and more contents, they basically became card catalogs and book shelves at once. This put the content out of easy reach without complex software and retrieval systems that only partial fit into humans' mental models. Agents now make files easy to work with again and store content in more directly understandable ways. Databases can return to their real job: indexing and finding. Databases are for finding things. The files are the record. If they disagree, the files win.

CSV for data that is inherently tabular

CSV is really only good when the tabular data is small, ideally numerical, with very short texts. Readings from weather stations are an example of data like this:

date,station,temperature_c,rainfall_mm,wind_kmh
2099-04-01,Plim-1,9.4,0.0,12
2099-04-01,Wug-2,7.2,0.8,24

Every row is complete, and every column holds one kind of value. CSV opens in any spreadsheet software, Git shows which rows changed, and an agent can embed it in a page as a table and a chart, as in the station readings example (the CSV).

One Markdown file per item for substantive records

If you want to store something more substantive, such as detailed responses, CSV is very difficult for people to read and analyse. Here is one row from a fictional survey of 12 researchers about using AI tools (the CSV). Role and discipline are codes, the five answers on a scale are numbers, and the two free-text answers are long quotations:

respondent_id,role,discipline,q1,q2,q3,q4,q5,q6_biggest_benefit,q7_main_concern
001,1,1,3,4,2,4,5,"I work with boxes of invented parish accounts for a teaching project, and the getting started part is what takes me longest. I can ask for ""three ways to index a receipt"" and use one as a starting point for my own list.

Last week that meant I spent an afternoon reading entries instead of fiddling with column headings. The index still changes whenever I find an exception, which is most weeks.","The transcriptions look more certain than the originals. I gave a tool a marked-up example with ""possibly six pence"" beside a blot, and its table came back with six pence and no qualifier.

I can catch that on a page I already know, but I am less sure I would notice after a hundred pages. I need my notes to keep the uncertainty visible alongside each amount."

To make sense of this row, you have to look up what role 1 and discipline 1 mean in the codebook, count columns to see which number answers which question, and read a paragraph squeezed into a cell.

It is much easier to put each item into a separate Markdown file with YAML metadata at the top. Markdown is just text: a person and an agent can read it in any editor. Here is the same respondent as respondent-001.md:

---
respondent_id: "001"
role: "Doctoral researcher"
discipline: "History"
q1: {"question": "I feel confident deciding when to use AI tools in my research.", "answer": 3, "label": "Neither agree nor disagree"}
q2: {"question": "AI tools save me time on routine research tasks.", "answer": 4, "label": "Agree"}
...
---

## Biggest benefit

I work with boxes of invented parish accounts for a teaching project, and the getting started part is what takes me longest. I can ask for "three ways to index a receipt" and use one as a starting point for my own list.
...

The short fields go in the YAML block, and the long answers are ordinary text under headings. From these files the agent builds the table, the database or the visualisation. The survey viewer shows the twelve respondents as cards, with filters and search, generated from the Markdown files, and the answers are much easier to review there than in the CSV. A researcher once sent me a spreadsheet hoping to hire a developer for a visualisation. An agent built an interactive view in minutes, and found errors in the data along the way.

Markdown

Markdown was developed to be a simple way encoding structured text with simple formatting to replace HTML. It is both easy to write and read by humans and LLMs model find it very understandable. Markdown can contain many different formats but the key markdown elements are:

Headings

#
##
###

Lists

- Bullet 1
- Bullet 2
- Bullet 3

1. item
2. item
3. item

Formatting

*italics*
**bold**

Markdown format also supports tables but, just like CSVs, they are not easy to write or read directly.

| respondent_id | role | discipline | q1 | q2 | q3 | q4 | q5 | q6_biggest_benefit | q7_main_concern |
|---|---:|---:|---:|---:|---:|---:|---:|---:|---|
| 001 | 1 | 1 | 3 | 4 | 2 | 4 | 5 | I work with boxes of invented parish accounts for a teaching project, and the getting started part is what takes me longest. I can ask for “three ways to index a receipt” and use one as a starting point for my own list.<br><br>Last week that meant I spent an afternoon reading entries instead of fiddling with column headings. The index still changes whenever I find an exception, which is most weeks. | The transcriptions look more certain than the originals. I gave a tool a marked-up example with “possibly six pence” beside a blot, and its table came back with six pence and no qualifier.<br><br>I can catch that on a page I already know, but I am less sure I would notice after a hundred pages. I need my notes to keep the uncertainty visible alongside each amount. |

Markdown files are plain text files conventionally named with the extension .md. Unfortunately, many computers will not open a .md file automatically and it is good idea to install a Markdown editor. I made my own called WriteFlex. Many people use Obsidian on their desktop and Notion also stores all contents as Markdown. People who work with code will also have text editors such as VS Code that also make it easy to work with Markdown.

When JSON is the right choice

JSON is a simple format for passing structured data between software tools. It is popular because it is relatively easy to read and write. JSON is less good for documents with large text passages. It is not as easy as Markdown with YAML metadata, and long free answers are no easier to read in JSON than in a CSV cell.

Where JSON works well is a table whose rows are not really tabular data: each row is a structured item with important content of its own. A word table in a grammar book is a good example. Each row gives a word, its part of speech, its meaning and an example sentence with a translation:

word,part_of_speech,gender_or_aspect,meaning,example,translation,note
kniha,noun,feminine,book,Čtu knihu.,I am reading a book.,knihu is the accusative form

In a table, the meaning of each value is somewhere else, in the header row, so you have to look it up. JSON lets you label every value in the item itself:

{
  "word": "kniha",
  "part_of_speech": "noun",
  "gender": "feminine",
  "meaning": "book",
  "example": {
    "sentence": "Čtu knihu.",
    "translation": "I am reading a book.",
    "note": "knihu is the accusative form"
  }
}

The word table in the examples has ten words like this, with a page that shows each word as a labelled card and the same data as a plain table for comparison (the CSV).

When you come across one item out of context, you can see what everything in it is without any lookups. The same is true for a screen reader, which reads the item with its labels instead of a row of cells, and for a language model, which reads complicated JSON more easily than a long CSV file. JSON is for storing items like these and making them easy to find; the tables, pages and exercises are built from it.

XML or TEI

Sometimes the contents of a file itself requires detailed annotation beyond simple structure. For example, grammatical annotation of individual words or structure. This is best served by a more complex format such as XML, or TEI, the vocabulary written in XML that is used in the digital humanities. However, as the level of detail increases, these documents become completely unreadable by humans.

<TEI xmlns="http://www.tei-c.org/ns/1.0">
  <text>
    <body>
      <p>
        Když <persName>Anna</persName> vystoupila na nádraží v
        <placeName>Brně</placeName>, <app>
          <lem>pršelo</lem>
          <rdg>mrholilo</rdg>
        </app>.
        V hale voněla káva. Vytáhla z batohu
        <title>Staré pověsti české</title>, ale než dočetla stránku,
        z reproduktoru se <app>
          <lem>ozvalo</lem>
          <rdg>zaznělo</rdg>
        </app> její jméno.
      </p>
    </body>
  </text>
</TEI>

These are covered in a separate guide.

Files you can find again

One of the reasons I prefer individual files with good names in folders is that I can find them later by searching. In a CSV or a database, whether you can find something depends on the technology.

Building views from the files

With agents, and scripts they write, the files can become websites, tables, databases and different visualisations whenever they are needed. Converting between a database and files used to be a project; now it is an afternoon. In the examples, the survey CSV is the original export from the survey tool. It was converted once into the respondent files, and from then on the files are the record: the viewer is built from them by a short script, build-examples.py, which an agent reruns whenever a file changes. In the age of agents, keeping data as files in this way is a win-win.

When you discuss storage with your agent, ask it to propose which of your data is inherently tabular and belongs in CSV, and which items should each get their own Markdown file.

Converting the workbook into clean tables

The agent converts the workbook by these rules.

  • One tidy table per file. Several tables on one sheet become several files.
  • One header row, with consistent column names.
  • A data dictionary. Units and codes are documented in a small file that describes each column.
  • Explicit columns. If a colour or a comment means something, that meaning becomes a column in the table.
  • The original workbook stays untouched as the source, with a note of where it came from.
  • A script does the conversion, not hand edits, so it can be rerun.

Because the original is kept and a script does the work, the tables can be rebuilt from the source at any time by running the script again.

Checking every update

The agent writes a validation script and runs it after every update. The script checks:

  • row counts;
  • types (numbers are numbers, dates are dates);
  • ranges of values;
  • that totals reconcile with the original workbook.

The result goes into the provenance record, the file that says where each data file came from.

Analysis with agents

The agent writes and runs the analysis code—Python with pandas, R or SQL—and saves the code with the results. Every table and chart can then be reproduced from the data and the code.

Some steps in an analysis are judgement calls: how to classify something, or what counts as an instance of a category. These are recorded as decisions, not hidden in code. Two of my public skills deal with this: judgement-vs-code (in the philosophy-for-agents folder) and research-reproducibility (in the research folder), both in my skills collection at https://github.com/techczech/dominiks-agent-skills.

Keeping the structure: AGENTS.md and skills

AGENTS.md is a file in the repository that tells agents how to work there. For a data repository it states:

  • the layout: where the original workbook, the tables, the data dictionary, the code and the results are kept;
  • the commands that run the conversion and the validation;
  • the naming rules;
  • "never edit the derived CSV by hand".

A skill captures a task that repeats, such as "add this month's export": where the new export goes, which script converts it, which checks to run and what to record in provenance.

With these two in the repository, the next agent that works on the data, yours or a collaborator's, keeps the same structure. The companion guide, Git and GitHub for sharing data with agents (coming soon), covers the repository itself: what goes in it, commits, and public and private repositories.

A worked example: the Research Snacks data repository

The data for Research Snacks (researchsnacks.semanticmachines.fyi) is in a public repository: https://github.com/techczech/research-snacks-data. It has the tables, the code, a validation script and a provenance record. It contains:

  • README.md, which explains the repository to people;
  • DATA-SOURCES.md;
  • LICENCE.md and a LICENSES/ folder;
  • VALIDATION.md and check.py, the validation an agent can run;
  • provenance.json;
  • code/ and snacks/;
  • pyproject.toml and uv.lock, which fix the Python packages and their versions so the code runs the same way again.

A Research Snack is a quick check of a public claim against the primary data. When I set up the repository in November 2026, four snacks were rerun from it, the 22 published tables reproduce, and a privacy scan passed. The working history stays in a separate private repository; this one is the public repository for reproducing the results.

Publishing the tables

Once the data is in clean tables, it can go on a static site, with the summaries computed at build time. The Astro guide covers this, including the options for large numerical data.

Open publishing and rights concerns

Whether you can publish the data depends on too many factors that don't have any universal rules. But you can also keep detailed metadata about rights and sources which makes it much easier to keep private data separate from public datasets.

Give this guide to your agent

Copy this and give it to your agent (Claude Code, Codex or another). The agent can read the whole guide and the rest of the series on this site, each page also as a Markdown file written for agents.

Read https://semanticmachines.fyi/guides/tabular-data-with-agents (and https://semanticmachines.fyi/llms.txt for the rest of the series), then help me convert and maintain my spreadsheets the way it describes. Start by asking me what I want to share.

What your agent takes from this guide

This is the practice the guide describes, written for the agent. It is here so that you can see what your agent will work from.

PRACTICE: TABULAR RESEARCH DATA

Purpose: keep research data in clean, documented tables that people and
agents can update, check and analyse reproducibly.

BEFORE CONVERTING ANYTHING
- Ask the user to describe the data and how it changes: who adds rows,
  how often, what questions the data must answer.
- Propose storage and give the reason:
  - CSV, one file per table: only for inherently tabular data (small,
    mostly numbers, very short text). Simple, diffable in Git.
  - Markdown with YAML metadata, one file per item: substantive records
    (long free-text answers, interview notes, records with long text).
    Short fields in YAML, long text as sections. Give each file a
    descriptive name so it can be found by searching.
  - JSON: tables whose rows are structured items (e.g. a grammar-book word
    table), every value labelled; not for records with long free text
    (each value carries its question, label or unit), so an item read
    out of context needs no lookups. For storing and finding.
  - SQLite or DuckDB: an index built from the files, for many related
    tables or millions of rows.
  - Parquet: large numerical data.
- The files are the record. A database is a derived index that can be
  rebuilt from them. If the files and the database disagree, the files
  win.
- Build tables, databases, viewers and charts from the files with
  scripts, and rerun the scripts when the data changes.
- Agree the update path with the user: rows appended to CSV, re-export
  from Excel, or a form.
- Write the agreed storage, layout and update path into AGENTS.md.

LAYOUT (example; adapt names to the project)
  README.md            what this is, for people
  AGENTS.md            layout, commands, naming rules, rules below
  sources/             original workbooks, unchanged, with a note of origin
  tables/              derived tables, one tidy table per file
  records/             one Markdown file with YAML per substantive item
  data-dictionary.md   each column: meaning, type, unit, codes
  code/                conversion script and analysis code
  analysis/            analysis outputs, beside the code that made them
  decisions.md         judgement calls and what was decided
  check.py             validation script
  provenance.json      each data file: where it came from, how it was
                       converted, results of the last check

CONVERSION
- One tidy table per file. Split several tables on one sheet into
  separate files. Separate totals from data.
- One header row. Consistent column names.
- Document units and codes in the data dictionary.
- Turn meanings carried by colours, comments or notes in cells into
  explicit columns.
- Never edit the original workbook.
- Convert with a script. Never edit a derived table by hand; change the
  script and rerun it.

CHECKS
- After every update, run the validation script: row counts, column
  types, value ranges, totals reconciled with the original workbook.
- Record the result in provenance.json.
- If a check fails, stop and report to the user.

ANALYSIS
- Write and run analysis code (Python with pandas, R or SQL). Save the
  code with the results so every table and chart can be reproduced.
- Record judgement calls (how to classify, what counts as X) as
  decisions in decisions.md. Do not hide them in code.

MAINTENANCE
- Keep AGENTS.md current: layout, conversion and validation commands,
  naming rules, "never edit the derived CSV by hand".
- Write a skill for each repeated task, e.g. "add this month's export":
  where the new file goes, which script converts it, which checks to
  run, what to record in provenance.

PUBLISHING AND PRIVACY
- Publish only data that you have permission to do so with. Use metadata to keep track of what is possible to share how.
- On a static site, compute summaries at build time.

Worked example: https://github.com/techczech/research-snacks-data

Cite this page

Lukeš, Dominik (n.d.). Spreadsheets and tabular data with agents · SemanticMachines. SemanticMachines. https://semanticmachines.fyi/guides/tabular-data-with-agents