CSV/TSV Tools

Parse, convert, and analyze CSV and TSV data files

Essential for data analysis, spreadsheet processing, and database import/export. CSV (Comma-Separated Values) is the universal format for tabular data exchange. Our tools help you parse, validate, convert, and analyze CSV files with support for various delimiters including tabs (TSV), semicolons, and pipes.

What is CSV?

CSV (Comma-Separated Values) is a simple file format used to store tabular data, such as spreadsheets or databases. Despite its simplicity, CSV has become the de facto standard for data exchange between different applications and systems.

History & Creation

CSV format has been used since the early days of computing. IBM Fortran supported a form of CSV in 1967, and the format was further popularized by spreadsheet programs like VisiCalc (1979) and Lotus 1-2-3 (1983). RFC 4180 formalized the CSV format in 2005.

Where CSV is Used

  • Data export/import between databases
  • Spreadsheet applications (Excel, Google Sheets)
  • Data science and machine learning datasets
  • Financial data and reports
  • E-commerce product catalogs
  • Log file analysis
  • Contact lists and CRM systems

Benefits Over Other Formats

  • vs Excel: Plain text format, no vendor lock-in, smaller file size, version control friendly
  • vs JSON: More compact for tabular data, easier to edit manually, direct spreadsheet compatibility
  • vs XML: Much simpler structure, smaller file size, faster to parse
  • vs Databases: Portable, no server required, human-readable, easy to share

Working with CSV Across Operating Systems

🪟 Windows

  • Excel for viewing/editing
  • PowerShell Import-Csv cmdlet
  • Notepad++ for text editing
  • csvkit command-line tools

🍎 macOS

  • Numbers or Excel
  • csvkit via Homebrew
  • awk/sed for processing
  • Python pandas library

🐧 Linux

  • LibreOffice Calc
  • csvtool command
  • awk, sed, cut utilities
  • miller (mlr) for analysis

CSV Format Variations

Standard CSV

  • Comma as delimiter
  • Double quotes for escaping
  • CRLF or LF line endings
  • Header row optional

Common Variations

  • TSV: Tab-separated values
  • PSV: Pipe-separated values
  • SSV: Semicolon-separated (European)
  • Fixed-width: Column-aligned text

Parse CSV/TSV Data

Upload or paste CSV/TSV data to parse and view in table format

CSV Format Examples & Best Practices

CSV files may seem simple, but proper formatting ensures compatibility across different systems. Here are comprehensive examples for various use cases.

Basic CSV Structures

Simple CSV with Header

Basic employee data with header row

Name,Email,Department,Salary
John Doe,john.doe@company.com,Engineering,75000
Jane Smith,jane.smith@company.com,Marketing,65000
Bob Johnson,bob.j@company.com,Sales,70000
Alice Brown,alice.b@company.com,Engineering,80000

CSV with Quoted Fields

Handling commas and special characters in data

Product,Description,Price,Category
"Laptop, 15 inch","High-performance laptop with 16GB RAM",1299.99,Electronics
"Coffee Maker","Programmable 12-cup coffee maker",79.99,Appliances
"Book: "Clean Code"","Robert C. Martin's programming guide",39.99,Books
"USB-C Cable, 6ft","Fast charging cable (USB 3.1)",19.99,Accessories

Different Delimiter Formats

Tab-Separated Values (TSV)

Using tabs for better compatibility with data containing commas

Date	Transaction	Amount	Balance
2024-01-15	Deposit	1000.00	5000.00
2024-01-16	Groceries	-87.43	4912.57
2024-01-17	Salary	3500.00	8412.57
2024-01-18	Rent	-1200.00	7212.57

Pipe-Separated Values (PSV)

Common in Unix/Linux environments and data pipelines

ID|Username|Full Name|Email|Role|Active
1001|jdoe|John Doe|jdoe@example.com|admin|true
1002|asmith|Alice Smith|asmith@example.com|user|true
1003|bwilson|Bob Wilson|bwilson@example.com|editor|false
1004|cjones|Carol Jones|cjones@example.com|user|true

Complex Data Scenarios

CSV with Line Breaks in Fields

Multi-line data enclosed in quotes

Title,Author,Description,ISBN
"The Great Gatsby","F. Scott Fitzgerald","A classic American novel
Set in the Jazz Age
Explores themes of wealth and love","978-0-7432-7356-5"
"To Kill a Mockingbird","Harper Lee","Pulitzer Prize winner
Deals with racial injustice
Set in Depression-era Alabama","978-0-06-112008-4"

Financial Data with Proper Formatting

Currency values and dates in standard format

Date,Account,Description,Debit,Credit,Balance
2024-01-01,Checking,"Opening Balance",0.00,5000.00,5000.00
2024-01-05,Checking,"Payroll Deposit",0.00,2847.53,7847.53
2024-01-07,Checking,"Electric Bill",127.45,0.00,7720.08
2024-01-10,Savings,"Transfer from Checking",0.00,1000.00,3500.00
2024-01-10,Checking,"Transfer to Savings",1000.00,0.00,6720.08

E-commerce Product Catalog

Product Inventory CSV

Complex product data with multiple attributes

SKU,Product Name,Category,Subcategory,Price,Stock,Weight,Dimensions,Color,Size,Tags
SHIRT-001,"Classic Cotton T-Shirt",Apparel,Shirts,19.99,150,0.2,"N/A","Red,Blue,White,Black","S,M,L,XL,XXL","cotton,casual,everyday"
LAP-15-512,"UltraBook Pro 15",Electronics,Laptops,1299.99,25,2.1,"35x24x1.8cm",Silver,"15 inch","laptop,portable,professional"
BOOK-PROG-01,"Clean Code: A Handbook",Books,Programming,39.99,75,0.5,"23x15x3cm",N/A,N/A,"programming,software,martin"
DESK-OAK-120,"Standing Desk - Oak",Furniture,Office,599.99,12,35.0,"120x60x75-125cm","Oak,Walnut","120cm","desk,adjustable,ergonomic"

Scientific Data Format

Experimental Data with Metadata

Scientific measurements with units and conditions

# Experiment: Temperature vs Pressure Study
# Date: 2024-01-20
# Researcher: Dr. Smith
# Units: Temperature (°C), Pressure (kPa), Volume (mL)

Sample_ID,Temperature,Pressure,Volume,Time,Notes
A001,25.0,101.3,100.0,0,"Baseline measurement"
A001,35.0,105.2,98.5,10,"Heated to 35°C"
A001,45.0,109.7,97.1,20,"Continued heating"
A001,55.0,114.5,95.8,30,"Maximum temperature"
A002,25.0,101.3,100.0,0,"Control sample"
A002,25.0,101.4,100.0,30,"No change observed"

Geographic Data

Location Data CSV

Coordinates and location information

Location_Name,Latitude,Longitude,Elevation_m,Population,Country,Type
"New York City",40.7128,-74.0060,10,8336817,USA,City
"Mount Everest",27.9881,86.9250,8849,0,Nepal/China,Mountain
"Amazon River","-3.0320",-60.0260,35,0,Brazil,River
"Tokyo",35.6762,139.6503,40,14094034,Japan,City
"Grand Canyon",36.1069,-112.1129,2100,0,USA,Landmark

Best Practices for CSV Files

Data Integrity

  • Always include a header row for clarity
  • Use consistent date formats (ISO 8601: YYYY-MM-DD)
  • Quote fields containing delimiters or line breaks
  • Escape quotes within quoted fields by doubling them
  • Use UTF-8 encoding for international characters

Common Pitfalls to Avoid

  • Excel Auto-formatting: Leading zeros removed, dates changed, scientific notation
  • Encoding Issues: Special characters corrupted when not using UTF-8
  • Inconsistent Delimiters: Mixing commas and semicolons in the same file
  • Unescaped Quotes: Breaking the CSV structure with unescaped quotation marks
  • Trailing Commas: Extra columns created by trailing delimiters

Processing CSV in Different Languages

Python - Reading CSV

Using pandas for powerful CSV manipulation

import pandas as pd

# Read CSV file
df = pd.read_csv('data.csv')

# Read with specific options
df = pd.read_csv('data.csv', 
                 delimiter=';',           # European semicolon
                 encoding='utf-8',        # Specify encoding
                 parse_dates=['Date'],    # Parse date columns
                 thousands=',',           # Thousand separator
                 decimal='.',             # Decimal separator
                 na_values=['N/A', ''])   # Custom NA values

# Basic operations
print(df.head())                         # First 5 rows
print(df.describe())                     # Statistical summary
print(df['Column'].value_counts())       # Frequency counts

# Write to CSV
df.to_csv('output.csv', index=False)

JavaScript - CSV Processing

Using PapaParse for browser and Node.js

// Parse CSV string
const results = Papa.parse(csvString, {
  header: true,           // First row is header
  dynamicTyping: true,    // Auto-detect numbers
  skipEmptyLines: true,   // Skip blank lines
  complete: (results) => {
    console.log('Parsed:', results.data);
    console.log('Errors:', results.errors);
  }
});

// Parse CSV file (browser)
Papa.parse(file, {
  header: true,
  complete: (results) => {
    // Process results.data
  }
});

// Convert JSON to CSV
const csv = Papa.unparse([
  { name: 'John', age: 30 },
  { name: 'Jane', age: 25 }
]);

// Stream large files
Papa.parse(file, {
  header: true,
  step: (row) => {
    // Process one row at a time
    console.log('Row:', row.data);
  },
  complete: () => {
    console.log('Parsing complete');
  }
});

SQL - Import/Export CSV

Database operations with CSV files

-- PostgreSQL: Import CSV
COPY customers(name, email, phone, country)
FROM '/path/to/customers.csv'
DELIMITER ','
CSV HEADER;

-- PostgreSQL: Export to CSV
COPY (SELECT * FROM orders WHERE order_date > '2024-01-01')
TO '/path/to/orders_2024.csv'
WITH (FORMAT CSV, HEADER);

-- MySQL: Import CSV
LOAD DATA INFILE '/path/to/products.csv'
INTO TABLE products
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '
'
IGNORE 1 ROWS;

-- SQLite: Import using CLI
.mode csv
.import data.csv table_name

-- SQL Server: Bulk insert
BULK INSERT Sales
FROM 'C:Datasales.csv'
WITH (
    FIELDTERMINATOR = ',',
    ROWTERMINATOR = '
',
    FIRSTROW = 2
);

Performance Optimization

For Large Files

  • Use streaming/chunked reading
  • Process data in batches
  • Consider binary formats for very large datasets
  • Use database imports instead of application parsing
  • Implement parallel processing where possible

Memory Efficiency

  • Read only required columns
  • Use appropriate data types
  • Filter data early in the pipeline
  • Consider compression (gzip) for storage
  • Use generators/iterators in code