Convert TeX Tables to CSV: What Survives the Trip and What Doesn't
A practical review of converting LaTeX/TeX tables to CSV: what changes, where merged cells, math and escapes break, and when plain text is the better choice.
Turning a TeX table into CSV moves data from a typesetting language into a plain, comma-separated format that spreadsheets, databases and scripts can read. The conversion is usually worthwhile when you need the numbers rather than the layout, but it is not lossless. This review explains what the transformation actually changes, where meaning can slip, and how to decide whether the result will serve your purpose.
A note on scope: no specific converter, website or software product was tested for this article, and no measured results are reported. The guidance below rests on how TeX table markup and the CSV format work in general. Where behavior depends on a particular tool or spreadsheet application, that is flagged rather than assumed.
Is converting a TeX table to CSV right for your use?
Recommendation: convert when the goal is to reuse the table's values, such as re-running calculations, charting the data, importing it into a database, or handing it to a colleague who does not use LaTeX. The main benefit is that cell contents become portable and editable in almost any data tool.
The decisive tradeoff is that CSV stores only a grid of text cells. Everything TeX uses to communicate structure and emphasis, such as merged cells, rules, captions, footnotes, alignment, bold headers and math formatting, either disappears or must be flattened into plain text. If a reader needs that structure to understand the table correctly, CSV alone will mislead them.
Plain text or the original source is preferable when the table is mainly explanatory rather than data-bearing, when it depends heavily on merged headers or multi-level grouping, when it contains substantial mathematical notation, or when it will be read by people rather than processed by software. In those cases, a short prose description, a plain-text rendering, or the TeX source itself often communicates better than a flattened CSV file.
What the conversion actually changes
First, a clarification about the input. "TeX table" most often means a LaTeX tabular-style environment (tabular, tabularx, longtable and similar), where ampersands separate cells and a double backslash ends a row. Plain TeX tables built with alignment primitives and tables in other TeX formats use different syntax, and a converter written for LaTeX tabular may not handle them. Converting the source code is also a different task from extracting a table from a compiled PDF; PDF extraction works from visual positions on the page and has its own, often larger, error sources.
Source-to-CSV conversion is a stored-character change, not a visual effect. The converter rewrites the characters in the file: TeX markup is removed or translated, cell boundaries become commas, and row endings become line breaks. Nothing about it depends on fonts or display settings. The core steps are:
- Cell separators: unescaped ampersands become field delimiters (commas for CSV, tabs for TSV).
- Row endings: the double backslash that ends each row becomes a line break.
- Rules and spacing: commands such as hline, toprule, midrule, bottomrule, cline and vertical-rule column specifiers are dropped, since CSV has no way to represent them.
- Escaped characters: TeX escapes such as backslash-ampersand, backslash-percent, backslash-dollar and backslash-underscore are turned back into the literal characters.
- Comments: unescaped percent signs start TeX comments, so text after them on a line should be discarded rather than copied into a cell.
- Formatting commands: wrappers such as bold, italic or color commands are either stripped to their contents or left as raw markup, depending on the tool.
- CSV quoting: any cell that contains a comma, a double quote or a line break is wrapped in double quotes, with internal double quotes doubled, following the widely used CSV convention.
Here is a small illustrative example. The input is a booktabs-style LaTeX table:
\begin{tabular}{lrr}
\toprule
Item & Q1 & Q2 \\
\midrule
Widgets, small & 1{,}200 & 1{,}350 \\
R\&D & 15\% & 18\% \\
\bottomrule
\end{tabular}
A correct CSV conversion of that table looks like this:
Item,Q1,Q2
"Widgets, small","1,200","1,350"
R&D,15%,18%
Checking the output against the mechanism: the three rule commands are gone; the escaped ampersand and percent signs have become literal characters; the TeX spacing group around the thousands comma has been removed, leaving 1,200; and every cell that now contains a comma is quoted so it is not split into two columns. A converter that skipped the quoting step would turn the second row into five fields instead of three, silently shifting values into the wrong columns. This is one of the most useful checks to run on any converter's output.
Merged cells and multi-row headers
Multicolumn and multirow commands have no CSV equivalent. A converter has to choose a flattening strategy, and the choice affects meaning:
| Strategy | Result for a header spanning two columns | Tradeoff |
| Value plus empty cells | Revenue,,Cost | Keeps the grid aligned, but the empty cell looks like missing data |
| Repeat the value | Revenue,Revenue,Cost | Keeps meaning in every column, but implies two separate values |
| Combine header rows | Revenue 2025,Revenue 2026,Cost | Readable and analysis-friendly, but usually needs manual editing |
For data analysis, a single header row with combined, unambiguous column names is usually the most practical outcome, even if it takes manual cleanup. Whatever strategy a tool uses, confirm that each data row still has the same number of fields as the header.
Math, symbols and macros
Math mode content and symbol commands are the second major decision point. A converter can keep them as raw TeX (for example, $\alpha$ stays exactly as written), substitute Unicode characters (α), or strip them. Keeping raw TeX preserves exact meaning for readers who know the notation but looks cluttered in a spreadsheet. Unicode substitution reads more naturally but only covers notation that has a single-character equivalent; fractions, subscripts with several characters, and structured expressions generally cannot be represented faithfully in a single CSV cell. Stripping removes information and should be treated as a loss.
Custom macros defined elsewhere in the document are a frequent gap. A converter that sees only the table cannot know what a user-defined command expands to, so it will either leave the command name in the cell or drop it. Values such as units, rounded numbers or symbols that depend on macros or table packages should be checked by hand against the compiled document.
Will the CSV stay readable and usable after sharing?
CSV is plain text, so copying and pasting it between text editors is generally reliable: there are no hidden styling characters to lose. The practical risks appear when the file is opened in a spreadsheet application, which interprets the text rather than simply displaying it. Behavior varies by application, version and locale settings, and none was tested for this review, so treat the following as things to check rather than guaranteed outcomes.
- Type guessing: values such as 1,200, 15%, 03-04 or codes with leading zeros may be converted to numbers, percentages or dates on import. Importing columns as text, where the application allows it, avoids silent changes.
- Delimiter and locale: in regions where the comma is the decimal separator, some applications expect semicolons as the CSV delimiter. TSV can sidestep this, since tabs rarely appear inside table cells.
- Character encoding: Unicode symbols and accented names should be saved as UTF-8, and it is worth confirming that the destination application reads the encoding correctly rather than assuming it will.
- Formula interpretation: a cell beginning with an equals sign, plus, minus or at sign may be treated as a formula by some spreadsheets. This matters for TeX content such as signed numbers or expressions, and is also a known security concern when CSV files come from untrusted sources.
- Line breaks inside cells: they are valid in quoted CSV fields but are handled inconsistently by line-based tools and some importers.
Reading order is generally straightforward in CSV because it is a strict grid read row by row, left to right. Accessibility, however, depends on what was lost. CSV has no markup for header cells, captions or table summaries, so assistive technology in a spreadsheet or text editor has no structural cue that the first row is a header unless the application or the user designates it. Captions, notes and footnote markers from the TeX source do not carry over automatically; if they explain units, abbreviations or significance markers, they need to travel separately. No specific screen reader or assistive technology was tested here.
Search and editing usually improve after conversion: plain cell values are easier to search and filter than TeX source full of commands. The exception is any cell where raw TeX markup was left in place, since a search for a value like 15% will not match text stored as 15%.
A plain-text equivalent or accompanying note is needed when the CSV will be shared with people rather than only processed by software, and especially when the original table relied on merged headers, footnotes, significance stars, units in the caption, or math that could not be flattened. A brief README or a notes column stating units, the meaning of empty cells and any symbols used keeps the data interpretable once it is separated from the paper or report it came from.
Choosing a conversion method
Options range from manual find-and-replace in a text editor, to a short script, to dedicated online or offline converters. Specific tools were not evaluated for this review, so their accuracy on merged cells, macros and escapes is unverified. Whatever you use, a few checks catch most problems:
- Field count: every row should have the same number of fields as the header.
- Escapes: no stray backslashes before ampersands, percent signs, dollar signs or underscores should remain unless you chose to keep raw TeX.
- Quoting: cells containing commas or quotes should be quoted, and the file should open with values in the correct columns.
- Spot comparison: compare a handful of cells, including any with math, merged headers or macros, against the compiled PDF rather than the source alone.
- Round trip in the destination: open the file in the application your audience will use and confirm numbers, dates and symbols display as intended.
If the table contains unpublished or sensitive data, consider an offline method. An online converter's appearance or description is not evidence of how it stores or handles uploaded content; check its stated privacy terms before pasting anything confidential.
Bottom line
Converting a TeX table to CSV is a sound choice when you need the values in a reusable, tool-friendly form and the table is essentially a simple grid. It becomes risky when meaning depends on merged cells, math, macros, captions or footnotes, because CSV cannot hold that structure. Verify field counts, escapes and quoting, watch for spreadsheet type guessing, and include a plain-text note whenever the flattened grid alone would leave a reader guessing.