# Data formats for working with agents: an overview

Most researchers keep their data in whatever format the application saved it in: Word documents, Excel workbooks, PDFs, the export from a survey tool. An AI agent such as Claude Code or Codex works on files in a folder. It searches the folder, names the files it found and chooses a tool for each format. So the format of a file decides which tool the agent can use on it and how much it can check.

This guide is the short reference on which format to keep research data in. It explains each format for a reader who has not had to think about file formats before, and ends with the practice your agent can work from. The demonstrations are in an interactive explainer, [What to keep your data in: files, formats and structures for working with agents](https://semanticmachines.fyi/explainers/data-structures-and-formats/), and the how-to is in the sibling guides. Each step has its own guide in this series - co-written with my agents based on the work they did for me. To make it simple, I use first person throughout:

1. [*Publishing research results with Cloudflare*](https://semanticmachines.fyi/guides/publishing-research-with-cloudflare): putting a folder of files online at a public address.
2. [*Building research sites from data files: Astro and fast search*](https://semanticmachines.fyi/guides/astro-and-fast-search): turning data files into a site people can search.
3. Git and GitHub for sharing data with agents (coming soon): keeping the files where collaborators and their agents can work on them.
4. [*Spreadsheets and tabular data with agents*](https://semanticmachines.fyi/guides/tabular-data-with-agents): turning workbooks into tables an agent can maintain.
5. [*From a pile of mixed documents to an agent-friendly knowledge repository*](https://semanticmachines.fyi/guides/knowledge-repository-for-agents): turning documents into a repository an agent can maintain.
6. *Data formats for working with agents: an overview* (this guide): which format to keep research data in.

## The short version

| Format | Use it for | Avoid it for | What an agent does with it |
|---|---|---|---|
| Plain text and Markdown | Notes, reports, chapters, anything mostly prose | Many rows of short values | Reads and edits it in any editor |
| Markdown with a YAML block | One record per file: interviews, survey responses, documents with fields such as date and status | Large regular tables | Sorts and filters records by field without reading the text; builds tables and sites from them |
| CSV | Small regular tables of numbers, dates and short text | Long text in cells; numeric codes that need a codebook | Reads it as a table, charts it, checks it with a script |
| JSON | Items whose values each need a label, such as dictionary entries | Records with long prose | Reads each item with its labels, with no lookups |
| Word, Excel and PDF | The original as it arrived, kept unchanged | The working copy of records you keep editing | Converts a copy to Markdown or tables with a script |
| Database (SQLite) | An index over many related tables or millions of rows | The only copy of the record | Builds it from the files and rebuilds it when they change |
| TEI XML | Editions that record witnesses, corrections, uncertainty and overlapping spans | Records that headings and fields already cover | Writes scripts that generate working formats from it |

The sections below explain each row.

## Data is a file in a folder

We use the word data for three layers and often mix them up. The signal is the bytes on the disk. The artefact is the file you can see in the folder. The content is what the file means to you. At the artefact layer, what you see is what there is, and you and the agent can point to the same file. Even data inside a database ends up as a file in a folder somewhere. [Section 1 of the explainer](https://semanticmachines.fyi/explainers/data-structures-and-formats/#files) shows an agent searching a folder in a made-up chat.

## Plain text and Markdown against Word and PDF

A Word document and a Markdown file can show the same report. A `.docx` file is a ZIP package, a compressed bundle of files, which holds the text and styles as XML (Extensible Markup Language, text marked up with tags). A tool has to open the package and interpret the XML to get at the text.

Markdown is plain text. The `.md` ending tells apps what is inside. A heading starts with `#`, a list item with `-`, and a table uses `|` between cells. A person and an agent can both read it in any editor. Plain text also lasts: the first file in Project Gutenberg, from 1971, is still readable. For Word, Excel and PDF files I keep the original unchanged and have the agent convert a copy. [Section 2 of the explainer](https://semanticmachines.fyi/explainers/data-structures-and-formats/#documents) puts a Word file and a Markdown file side by side.

## YAML metadata at the top of a file

YAML is a notation for named fields. In a Markdown file it sits in a block between two lines of three dashes at the top:

```yaml
---
title: Water point check, northern district
date: 2099-03-14
status: checked
---
```

An agent can sort by date, filter by status or look up a title without reading the paragraphs below. In my own repositories the block also says where the file came from and how it was converted, so a statement can be traced back to the original document. [Section 3 of the explainer](https://semanticmachines.fyi/explainers/data-structures-and-formats/#metadata) lets you use the fields on a list of six records.

## CSV, and where it stops working

CSV (comma-separated values) is a plain text file with one row per line and the values separated by commas. It fits regular data such as daily weather readings: every row has the same columns, and the values are mostly numbers, dates and short text.

It stops working when the answers are long. A survey export puts a multi-paragraph answer in quotes and doubles every quotation mark inside it, and you need a separate codebook to read the numeric codes. For records like these I keep one Markdown file per item, with the fields I want to filter on in YAML and the long answers below them as sections, and build tables and viewers from those files. [*Spreadsheets and tabular data with agents*](https://semanticmachines.fyi/guides/tabular-data-with-agents) covers this with examples, and [section 4 of the explainer](https://semanticmachines.fyi/explainers/data-structures-and-formats/#csv) demonstrates it.

## JSON when each value needs its label

JSON (JavaScript Object Notation) writes every value next to its label, for example `"part_of_speech": "noun"`. In a CSV table the meaning of each value is in the header row, so you have to look it up. Where a row is really a structured item with content of its own, such as a dictionary entry with an example sentence, a translation and a note, JSON keeps all of it together. An item you come across out of context needs no lookups. A screen reader reads it with its labels, and I find that a language model reads complicated JSON more easily than a long CSV file.

JSON is rarely the right choice for records with long prose. Those are easier to read as Markdown with YAML. [Section 5 of the explainer](https://semanticmachines.fyi/explainers/data-structures-and-formats/#json) shows one Czech dictionary entry as a CSV row and as JSON.

## Files are the record, databases are the index

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 understood where to look. That stopped working at scale, so databases took over storage and put the data behind an application. Agents make files easy to work with again, and databases can go back to their real job. Databases are for finding things. The files are the record. If they disagree, the files win. A database such as SQLite (a database kept in a single file) is a good index and a brittle place to keep the record.

The same rule covers intermediate files: indexes, caches (saved results, so that they need not be computed again) and derived tables (tables generated from the files). Each is generated from the record by a script, so it can be thrown away and rebuilt. A correction made only in a derived table is not in the record, so make corrections in the files and rebuild. Speed belongs to the index and durability to the record.

Two published figures show the difference. The developers of ParlaMint, a collection of parliamentary debates, report over 240 GB and almost 160,000 files for the first release in Git, and about four hours to stage and commit the complete corpora. A change in automated annotation can affect nearly all files, so they kept small samples in GitHub and used a separate corpus repository for distribution ([TEI and Git in ParlaMint](https://ecp.ep.liu.se/index.php/clarin/article/download/727/633/745)). In a 2021 DuckDB experiment, counting rows in about 21 million taxi records stored as roughly 360 MB of Parquet (a compact file format for large tables) took 0.015 seconds in DuckDB and 7.5 seconds when Pandas read the whole file ([DuckDB](https://duckdb.org/2021/06/25/querying-parquet)). No source I have found compares all these formats on one workload. [Section 6 of the explainer](https://semanticmachines.fyi/explainers/data-structures-and-formats/#index) shows an agent rebuilding an index from the files in a made-up chat.

## When Markdown and YAML are not enough: TEI

TEI is the set of guidelines from the Text Encoding Initiative for representing texts in XML. It lets an edition record, inside the text, which witness has which reading (a witness is a source that attests a version of a text), editorial corrections, how uncertain an editor is, and spans that overlap, such as a speech turn that crosses a page boundary ([critical apparatus](https://tei-c.org/release/doc/tei-p5-doc/en/html/TC.html)). Markdown with YAML has no agreed way to write these down.

Large projects keep TEI as the record and generate working formats from it. ParlaMint keeps annotated TEI XML and generates CoNLL-U (a tab-separated format for linguistic analysis) and vertical files for concordance tools ([ParlaMint release](https://www.clarin.si/repository/xmlui/handle/11356/2005)). An agent can write the conversion script. A schema, a set of rules for what the XML may contain, can check the structure of the result. It cannot tell you whether a reading has been assigned to the right witness; that has to be checked against the source. A separate explainer on TEI is planned.

## Embeddings

An embedding is a list of numbers computed from a passage of text, so that passages with similar content get similar numbers. In my talk I called them semantic fingerprints. They are useful for finding similar passages. They are secondary now that an agent can load 20 long documents and answer questions about them at once. If you do make embeddings, keep with each vector the file, the passage identifier and the version it came from, so that a hit points back to exact words.

## Converting between formats

Converting between files and a database used to be a project. For a folder like the one in the explainer, it can now be an afternoon. The consequence runs through everything above: keep the record in the richest format the material needs, ask the agent to write the conversion to whatever a task needs, and check the output.

What is evidenced: ParlaMint generates its working formats from a TEI record. Causin and colleagues used language models to add named-entity markup and Wikidata identifiers to already encoded TEI, in 34 articles. Their automated review found incorrect links among annotations marked high-confidence, and human review missed four out of five mismatches in the paper's sample. They also report three instances of malformed XML after model or human edits, and name parsing as a missing check ([paper](https://doi.org/10.66532/jhai.2026.0023)). That is why I ask for validation after every conversion.

What is my argument: that a conversion script written on demand makes it practical to keep a rich record and project it into several working formats. The sources I have do not measure agent-written converters across projects or how much labour they save. A script can repeat a mapping, but a distinction the record leaves out stays missing until someone supplies evidence.

## 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/data-formats-for-working-with-agents (and https://semanticmachines.fyi/llms.txt for the rest of the series), then help me choose and set up formats for my research data the way it describes. Start by asking me what material I have and what I want to do with it.

### 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.

```markdown
# Practice: choosing and converting research data formats

Purpose: keep research data in formats that people and agents can read, check
and reuse, and convert between them safely.

## Inspect first
- List the folder and count the files by extension. Report what is there
  before proposing anything.
- Ask the user what the material is, how it changes, who updates it and what
  questions it must answer.
- Do not convert, move or delete anything at this stage.

## Propose a format for each kind of material
- Prose (notes, reports, chapters): Markdown.
- One record per item with fields such as date and status: Markdown with a
  YAML block at the top. Short fields in YAML, long text as sections under
  headings. Give each file a descriptive name.
- Small regular tables (numbers, dates, short text): CSV, one tidy table per
  file, one header row.
- Items whose values each need a label (dictionary entries): JSON. Not for
  records with long prose.
- Word, Excel and PDF: keep the original unchanged in a sources/ folder and
  convert a copy to Markdown or CSV with a script.
- Many related tables or millions of rows: SQLite or DuckDB as an index.
  Parquet for large numerical tables.
- Editions that record witnesses, editorial corrections, uncertainty or
  overlapping spans: TEI XML as the record. Ask the user whether the project
  already uses it.
- Explain each proposal to the user in plain words.

## Record and index
- The files are the record. A database, cache, search index or derived table
  is generated from them by a script and can be deleted and rebuilt.
- If a derived copy and the files disagree, the files win. Make corrections
  in the record, then rebuild. Never edit a derived table by hand.
- If you make embeddings, store with each vector the file, passage identifier
  and version it came from, so that a hit points back to exact words.

## Convert safely
- Ask the user before converting a file or deleting an original. Keep
  originals.
- Convert with a script saved in the repository so that it can be rerun.
- After each conversion validate: row counts, types, value ranges and that
  the text matches the source. For XML, parse it and check it against the
  schema.
- A schema checks structure only. Check a sample against the source to see
  whether each reading, label and value is right, and report what you checked.
- Write the chosen formats, the layout and the rebuild commands into AGENTS.md.
```
