Load CSV data with LlamaIndex

How LlamaIndex turns CSV and TSV rows into documents, which reader to choose, what the conversion changes, and when a structured query approach works better.

Loading a CSV file into LlamaIndex is a text transformation. Rows and columns become Document objects, those documents are usually split into nodes and embedded, and a language model later reads whatever text retrieval returns. Whether that works depends on what you want to ask of the data. This review covers what the conversion changes, which reading approach fits which goal, and where the tabular structure stops being useful.

Evidence note: no benchmarks, test results or version-specific measurements were supplied for this review. Class names and parameters below describe commonly documented LlamaIndex file readers. Reader names, import paths and defaults have changed between releases, so check them against the documentation for the version you have installed before you rely on them.

Is LlamaIndex CSV loading suitable for your use?

Recommendation: use a LlamaIndex CSV reader when the spreadsheet mainly holds descriptive text you want to search by meaning. Good examples are product descriptions, support tickets, FAQ entries or notes, where each row stands on its own. The main benefit is that a row can be found through a natural-language question even when the question uses none of the exact words in the cell.

The decisive tradeoff is that semantic retrieval returns a handful of similar chunks, not the whole table. Questions such as totals, averages, counts, maximums, or filters across every row can come back incomplete or wrong, because the model only sees the rows that were retrieved. For numeric or analytical questions, keep the data structured. One option is a table-aware query engine, such as a pandas-based or text-to-SQL engine (check which package provides it in your version). The other is to run the calculation directly in pandas or SQL.

Plain text, or the original CSV, is the better choice in several cases: the file is small enough to pass whole to the model, you need exact values that can be audited, or the columns are mostly numbers and codes with little prose for embeddings to work with.

What the conversion actually changes

Here, 'reverse', 'mirror' and 'font' do not apply. Nothing is reordered or restyled visually. The change is structural. A CSV file stores values in a grid whose meaning comes from the header row and the column positions. A LlamaIndex reader parses that grid and writes it out as text, and the reader determines how much of the structure survives.

  • Concatenated rows: the reader joins rows into one large document, with values separated by a joiner character. The grid becomes a single block of text, and later chunking can split it in the middle of a row.
  • One document per row: each row becomes its own document. Row boundaries survive chunking, which helps retrieval precision.
  • One document per row with column labels: each value is written next to its column name, so a row reads as 'column: value' lines. The header meaning stays attached to every value instead of existing only in the first line of the file.
  • Metadata: some workflows keep selected columns, such as an ID or category, as document metadata rather than embedded text. That allows filtering without mixing identifiers into the semantic content.

The commonly documented readers in the file readers package map onto these patterns. A basic CSVReader and a PandasCSVReader each expose a concat_rows option that switches between one combined document and one document per row. The pandas-based reader also accepts column and row joiner settings, plus a pandas_config dictionary that is passed to pandas when it parses the file. A PagedCSVReader produces one labeled document per row. When you load a folder with SimpleDirectoryReader, a default reader is chosen by file extension, so check which reader handles .csv in your version instead of assuming its row behavior.

from pathlib import Path
from llama_index.readers.file import PagedCSVReader

reader = PagedCSVReader()
documents = reader.load_data(file=Path("data/products.csv"))

The example below is illustrative and was not captured from a test run. It shows the general shape a labeled per-row conversion aims for. Given a header of sku,name,description and a row of A12,Desk lamp,Adjustable arm with warm LED, a labeled row document would read roughly as follows.

sku: A12
name: Desk lamp
description: Adjustable arm with warm LED

Compare this with a concatenated conversion, where the same values might appear as 'A12, Desk lamp, Adjustable arm with warm LED' in a long run of other rows. The labeled form costs more tokens per row. In exchange, it tells the model which value is the SKU and which is the description, which matters when headers carry meaning the values do not.

Loading TSV and other delimited files

Tab-separated files use the same row-and-column model with a different delimiter. With the pandas-based reader, you can pass the separator to pandas through pandas_config. Readers built on Python's csv module may or may not expose a delimiter option, so check before pointing one at a TSV file. If a TSV is parsed as comma-separated, each line usually arrives as one undivided field. The loader will not report an error, but the column structure is lost.

from pathlib import Path
from llama_index.readers.file import PandasCSVReader

reader = PandasCSVReader(concat_rows=False, pandas_config={"sep": "\t"})
documents = reader.load_data(file=Path("data/products.tsv"))

Will the loaded data stay readable and usable downstream?

After loading, the main question is whether the text a model receives still carries the meaning the table had. Several common failure points are worth checking before you build an index.

Issue | What happens | What to check
Quoted fields containing commas or line breaks | A naive split breaks one value into several, or one row into several | Use a reader backed by a real CSV parser and inspect a few documents that contain such fields
Encoding and byte-order marks | Non-ASCII text can be garbled, or the first header can pick up a stray character | Confirm the file encoding and pass it through the parser settings if needed
Missing or empty values | Empty cells may appear as blank labels or as placeholder text such as NaN | Decide whether to drop, fill or keep them before loading
Long cells | A single row may exceed the chunk size and be split | Review chunk size, or move long text into its own documents
Numeric-heavy columns | Embeddings capture little about bare numbers, so retrieval by value is unreliable | Use metadata filters or a structured query engine for these columns
Very large files | Concatenation creates one oversized document; per-row loading creates many small ones | Weigh per-row documents against cost and index size

Keep a plain-text or original-format copy whenever answers must be verified. A generated answer is only as complete as the retrieved rows, so the source CSV remains the reference for exact figures. If the rows contain personal or confidential data, remember that embedding and generation steps that call a hosted model send that text to the provider. Check that provider's own documentation for data handling rather than assuming anything from the integration itself.

Choosing an approach

  • Mostly prose in each row, with questions about meaning: load one document per row, preferably with column labels.
  • A small file and broad questions: consider passing the CSV text directly instead of building an index.
  • Aggregations, filters or exact lookups: keep the data in a dataframe or database and use a table-aware query engine or direct queries.
  • Mixed tables: embed the descriptive columns and keep IDs, categories and numbers as metadata or in a structured store.

Open gaps: this review has no measured comparison of retrieval quality, speed or cost between these readers, and no confirmation of the defaults in any particular LlamaIndex release. Inspect a sample of the loaded documents for your own file before indexing. That check shows directly whether the conversion preserved the structure you need.