.CSV Comma-Separated Values
.csv

Comma-Separated Values

CSV stores tabular data as plain text with comma-delimited fields and CRLF-terminated records, governed by RFC 4180. Every spreadsheet, database, and programming language reads CSV, making it the lowest-common-denominator format for structured data exchange.

بنية الصيغة
Header schema
Records structured data
Tabular Datatext/csvRFC 4180Plain Text1972 OriginUniversal
بواسطة FileDex
غير قابل للتحويل

CSV is plain text tabular data. Semantic conversion to other data formats requires schema mapping.

أسئلة شائعة

Why does Excel show all CSV data in one column?

Excel uses the Windows system locale's list separator, which is semicolon in most European locales (German, French, Dutch). If your CSV uses commas but the locale expects semicolons, all fields merge into column A. Fix by using Data > From Text/CSV import with explicit comma delimiter, or change the list separator in Windows Regional Settings.

How do I open a UTF-8 CSV file in Excel without garbled characters?

Add a UTF-8 BOM (EF BB BF) to the first byte of the file, or use Data > From Text/CSV and select 65001: Unicode (UTF-8) as the file origin. Excel defaults to the system code page (often Windows-1252) when opening CSV directly, which corrupts non-ASCII characters.

What is the difference between CSV and TSV?

CSV uses comma (0x2C) as the field delimiter. TSV uses tab (0x09). TSV avoids the quoting complexity of CSV because tabs rarely appear in data values, but TSV cannot represent fields containing tab characters without escaping. Both are plain text tabular formats covered by similar parsing logic.

How do I handle commas inside a CSV field?

Per RFC 4180, enclose the field in double quotes. A field value like 'New York, NY' becomes "New York, NY" in the CSV. Double quotes inside a quoted field are escaped by doubling: "She said ""hello""" represents the string She said "hello".

ما يميز .CSV

What is a CSV file?

CSV (Comma-Separated Values) is a plain text format for storing tabular data. Each line represents a row, and values within each row are separated by commas (or other delimiters). CSV is the simplest and most universal format for data exchange between spreadsheets, databases, and applications.

اكتشف التفاصيل التقنية

How to open CSV files

  • Microsoft Excel (Windows, macOS) — Spreadsheet view
  • Google Sheets (Web) — Free, online
  • LibreOffice Calc (Windows, macOS, Linux) — Free
  • Any text editor — Raw text view
  • Python / pandas — Programmatic analysis

Technical specifications

Property Value
Delimiter Comma (or semicolon, tab)
Encoding UTF-8, ASCII, etc.
Quoting Double quotes for special characters
Header Optional first row as column names
Standard RFC 4180

Common use cases

  • Data export: Database and spreadsheet exports
  • Data import: Bulk data loading
  • ETL pipelines: Extract-Transform-Load workflows
  • Reporting: Simple data reports

المرجع التقني

نوع MIME
text/csv
المطوّر
IBM (earliest usage)
سنة التقديم
1972
معيار مفتوح
نعم — عرض المواصفات

البنية الثنائية

CSV is a text format with no binary structure. Each line represents one record (row), terminated by CRLF (0x0D 0x0A) per RFC 4180, though many implementations accept bare LF (0x0A). Fields within a record are separated by a comma (0x2C). Fields containing commas, double quotes, or newlines must be enclosed in double quotes (0x22). A double quote within a quoted field is escaped by doubling it ("" represents a literal "). The first record may be a header row with column names, but RFC 4180 section 2.3 states this is optional and there is no in-band mechanism to distinguish a header row from data. CSV has no type system — all values are strings, and type interpretation (integer, float, date, boolean) is left to the consuming application. There is no standard encoding declaration; files may be UTF-8, Windows-1252, ISO-8859-1, or other encodings with no way to distinguish them without heuristics. Excel on Windows defaults to the system locale's encoding (often Windows-1252) and uses the system locale's list separator (semicolon in many European locales instead of comma). A UTF-8 BOM (EF BB BF) at byte 0 signals UTF-8 to Excel but may cause issues with other parsers that do not expect a BOM.

1972Earliest documented use of comma-separated data in IBM Fortran programs for data input1983Lotus 1-2-3 popularizes CSV as a spreadsheet interchange format on IBM PC1987Microsoft Excel 2.0 adds CSV import/export, cementing CSV as the universal spreadsheet exchange format2005RFC 4180 published — first formal specification for CSV format, defining MIME type text/csv2013W3C publishes CSV on the Web working group recommendations for metadata and transformation2014RFC 7111 extends RFC 4180 with URI fragment identifiers for addressing CSV rows, columns, and cells
Select specific columns from a CSV file أخرى
csvtool col 1,3,5 input.csv > output.csv

csvtool extracts columns by position number (1-indexed). Handles quoted fields and embedded commas correctly, unlike naive cut -d',' commands.

Convert CSV to JSON with Miller أخرى
mlr --icsv --ojson cat input.csv > output.json

Miller (mlr) reads CSV and outputs JSON with automatic type inference. Each row becomes a JSON object with column headers as keys. Handles quoting and escaping per RFC 4180.

Query CSV with SQL using DuckDB أخرى
duckdb -c "SELECT * FROM 'input.csv' WHERE amount > 1000 ORDER BY date"

DuckDB reads CSV files directly as virtual tables, enabling full SQL queries without importing to a database. Auto-detects headers, delimiters, and column types.

Fix CSV encoding to UTF-8 أخرى
iconv -f WINDOWS-1252 -t UTF-8 input.csv > output.csv

Converts CSV from Windows-1252 encoding to UTF-8. Fixes garbled accented characters, currency symbols, and special characters caused by encoding mismatch.

Count rows and preview CSV structure أخرى
head -5 input.csv && echo '---' && wc -l input.csv

Shows the first 5 rows (including header) to verify column structure, then counts total lines. Useful for quick sanity checks before processing large CSV files.

CSV JSON render lossless Web APIs and JavaScript applications expect JSON. Converting CSV to JSON maps each row to an object with column headers as keys, enabling direct consumption by fetch()-based frontends and Node.js backends.
CSV XLSX render lossless Excel workbooks support multiple sheets, cell formatting, formulas, and charts that CSV cannot express. Converting CSV to XLSX enables adding calculated columns, conditional formatting, and pivot tables for business reporting.
CSV PARQUET render lossless Parquet is a columnar binary format with built-in compression and type metadata. Converting CSV to Parquet reduces file size by 60-90% and enables predicate pushdown in query engines like DuckDB, Spark, and BigQuery.
CSV SQL render lossless Importing CSV into a relational database enables SQL queries, joins, indexing, and ACID transactions. Each CSV column maps to a table column with inferred or declared types.
منخفض

نقاط الضعف

  • Formula injection (CSV injection) — cells starting with =, +, -, or @ are executed as formulas when opened in Excel or Google Sheets, enabling DDE command execution or data exfiltration via HYPERLINK()
  • Encoding-based data manipulation — saving CSV as Windows-1252 then re-importing as UTF-8 silently corrupts numeric data containing locale-specific decimal separators or currency symbols
  • Oversized row denial of service — a single CSV row with millions of fields or a multi-gigabyte quoted field exhausts parser memory

الحماية: FileDex processes CSV files entirely in the browser with no server upload. CSV parsing uses standard text processing with no formula execution. Cells are treated as raw strings, not spreadsheet formulas.

pandas مكتبة
Python data analysis library with CSV read/write, type inference, and DataFrame operations
Miller (mlr) أداة
CLI tool for CSV, TSV, JSON transformations — like awk, sed, and sort for structured data
DuckDB أداة
Embedded analytical database that queries CSV files directly with SQL
csvkit أداة
Python CLI suite for CSV — csvcut, csvgrep, csvsort, csvjson, and csvstat
Papa Parse مكتبة
Fast in-browser CSV parser for JavaScript with streaming and web worker support
LibreOffice Calc أداة
Open-source spreadsheet with CSV import wizard for delimiter and encoding selection