Перейти к основному содержимому
FreeOnlineTools Go
Русский
comparison

CSV против TSV: Какой формат разделителя выбрать?

By · Updated 2026-09-02

Quick Answer

Используйте CSV для общего обмена данными, импорта/экспорта таблиц и максимальной совместимости. Используйте TSV когда данные содержат запятые, но не табы, чтобы избежать quoting и экранирования. TSV распространён в биоинформатике и NLP; CSV — универсальный default.

Introduction

CSV (Comma-Separated Values) и TSV (Tab-Separated Values) — два plain-text формата для табличных данных. Оба хранят строки как линии с полями, разделёнными разделителем. CSV использует запятые; TSV использует табы. Выбор разделителя влияет на экранирование, совместимость с электронными таблицами и обработку текстовых полей, содержащих разделитель.

Step by Step

  1. Compare delimiter and escaping

    CSV uses commas. If a field contains a comma, it must be wrapped in quotes: "Smith, John". If a field contains quotes, they must be escaped: "He said ""hello""". TSV uses tabs. Tabs rarely appear in text data, so TSV fields usually need no quoting or escaping — simpler parsing.

  2. Compare compatibility

    CSV is universally supported: Excel, Google Sheets=Sheets, every database, every programming language. TSV is also widely supported but less standardized — some tools interpret tabs differently. Excel auto-detects both, but CSV is the default export format.

  3. Compare parsing complexity

    CSV parsing requires a state machine to handle quoting rules (RFC 4180). TSV parsing is trivial: split each line by tab character. This makes TSV faster to parse and less error-prone. However, CSV has a formal spec (RFC 4180); TSV has no formal standard.

  4. Compare use cases

    CSV: spreadsheet import/export, data APIs, ETL pipelines, config files, universal data exchange. TSV: bioinformatics (BLAST, GFF), NLP (CoNLL format), clipboard data (copy from Excel = TSV), log files with tab delimiters.

  5. Decide based on your data

    If your data contains commas (names, addresses, sentences): TSV avoids quoting. If your data contains tabs (rare in text): CSV avoids quoting. If you need maximum compatibility: CSV. If you want simpler parsing and your data is tab-free: TSV.

Examples

Same data in CSV and TSV

Input: CSV: name,age,city\n"Smith, John",30,"New York, NY"\nTSV: name\tage\tcity\nSmith, John\t30\tNew York, NY

Output: CSV requires quotes for fields with commas. TSV needs no quoting because tabs don't appear in the data.

Common Problems

  • CSV quoting edge cases: fields containing commas, quotes, or newlines require RFC 4180 quoting rules — a naive split by comma will corrupt data with embedded commas.
  • TSV has no formal standard: unlike CSV (RFC 4180), TSV has no official spec, so tools may handle edge cases differently — use TSV only within controlled pipelines.
  • Excel encoding issues: Excel may export CSV with BOM or locale-specific delimiters (semicolon in EU locales) — specify UTF-8 encoding and verify delimiter on import.
  • Newline ambiguity: CSV fields with embedded newlines are valid but break line-by-line parsing — TSV rarely has this problem because tabs are uncommon in text data.

Tips

  • Use CSV for maximum compatibility — every spreadsheet, database, and programming language supports it natively.
  • Use TSV when your data contains commas but not tabs (names, addresses, sentences) to avoid quoting complexity entirely.
  • Always use a proper CSV parser (not string.split) to handle RFC 4180 quoting rules — naive splitting corrupts fields with embedded commas or quotes.
  • When copying data from Excel to a text editor, the clipboard uses TSV format — paste into a .tsv file to preserve fields with commas correctly.

Related Tools

Related Guides

References