Understanding Delimiters
A delimiter is a character that separates values in a data file. Different systems and applications use different delimiters, and converting between them is essential for data import/export workflows.
Common Delimiter Types
| Format | Delimiter | Extension | Use Case |
|---|---|---|---|
| Excel Column | Newline (\n) | .txt | Excel paste, one value per row |
| CSV | Comma (,) | .csv | Most common, universal support |
| TSV | Tab (\t) | .tsv, .txt | Excel, database imports |
| Pipe | Pipe (|) | .txt | Systems that allow commas in data |
| Semicolon | Semicolon (;) | .csv | European Excel (uses comma as decimal) |
When to Use Each Format
Excel Column Format (Newline)
Best for:
- Pasting directly into Excel (one value per cell vertically)
- Creating dropdown lists in Excel data validation
- Importing into database tables (one row per value)
- Reading line-by-line in scripts
AAPL MSFT GOOGL
Comma-Separated (CSV)
Best for:
- Universal data exchange
- Importing to most applications
- Email lists, contact lists
- Web form submissions
AAPL, MSFT, GOOGL
Tab-Delimited (TSV)
Best for:
- Excel data with commas in values
- Database bulk imports (PostgreSQL COPY)
- Clipboard operations between applications
- Log file parsing
AAPL MSFT GOOGL
Pipe-Delimited
Best for:
- Data containing commas and tabs
- Legacy database systems
- Unix/Linux data processing
- ETL pipelines
AAPL | MSFT | GOOGL
Semicolon-Separated
Best for:
- European Excel (comma is decimal separator)
- Localized applications
- Regional data standards
AAPL; MSFT; GOOGL
Excel Integration
Importing to Excel
Method 1: Text to Columns
- Paste your delimited data into Excel
- Select the cell(s)
- Data tab → Text to Columns
- Choose "Delimited"
- Select your delimiter (Comma, Tab, Other)
- Finish
Method 2: Import Data
- Data tab → Get Data → From Text/CSV
- Select your file
- Excel auto-detects delimiter
- Click Load
Exporting from Excel
Save As Formats:
- CSV (Comma delimited): .csv file
- CSV (Macintosh): Mac line endings
- CSV (MS-DOS): Windows line endings
- Text (Tab delimited): .txt file
- Unicode Text: UTF-16 tab-delimited
Database Import Examples
PostgreSQL COPY
-- Tab-delimited import
COPY tickers FROM '/path/to/file.tsv'
DELIMITER E'\t'
CSV HEADER;
-- Pipe-delimited import
COPY tickers FROM '/path/to/file.txt'
DELIMITER '|'
CSV HEADER; MySQL LOAD DATA
-- CSV import
LOAD DATA INFILE '/path/to/file.csv'
INTO TABLE tickers
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS; SQL Server BULK INSERT
-- Tab-delimited import
BULK INSERT tickers
FROM 'C:\data\file.tsv'
WITH (
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n',
FIRSTROW = 2
); Programming Examples
Python
import csv
# Read CSV
with open('tickers.csv') as f:
reader = csv.reader(f)
tickers = [row[0] for row in reader]
# Write pipe-delimited
with open('tickers.txt', 'w') as f:
f.write('|'.join(tickers))
# Using pandas
import pandas as pd
df = pd.read_csv('tickers.csv')
df.to_csv('output.tsv', sep='\t', index=False) JavaScript
// Convert CSV to array
const csv = "AAPL,MSFT,GOOGL";
const array = csv.split(',').map(s => s.trim());
// Convert array to pipe-delimited
const piped = array.join(' | ');
// Convert to newline-separated
const column = array.join('\n'); Excel VBA
Sub ConvertDelimiter()
Dim cell As Range
Dim arr() As String
' Split comma-separated value
arr = Split(ActiveCell.Value, ",")
' Output as column
For i = LBound(arr) To UBound(arr)
ActiveCell.Offset(i, 0).Value = Trim(arr(i))
Next i
End Sub Common Issues & Solutions
Issue #1: Commas Within Data
When your data contains commas:
❌ CSV: "Apple, Inc.", MSFT, GOOGL (breaks on first comma)
✓ TSV: "Apple, Inc." MSFT GOOGL (preserves commas)
✓ Pipe: "Apple, Inc." | MSFT | GOOGL (preserves commas) Issue #2: Excel Auto-Formatting
Excel may interpret tickers as dates or numbers:
- Prefix with apostrophe:
'AAPL - Format cells as Text before pasting
- Use Power Query to import as text
Issue #3: Line Ending Differences
- Windows: \r\n (CRLF)
- Unix/Mac: \n (LF)
- Old Mac: \r (CR)
Most modern applications handle all three automatically.
Best Practices
Choose the Right Delimiter
- Know what characters might appear in your data
- Match the format to your destination system
- Document the delimiter used in file names (e.g., data_pipe.txt)
Handle Special Characters
- Quote fields containing delimiters
- Escape quotes within quoted fields ("")
- Consider using a rare delimiter (e.g., pipe) if data is complex
Test Imports
Always test with a small sample before importing large datasets:
- Export 5-10 rows
- Test import to destination
- Verify data integrity
- Then import full dataset
Quick Reference
| Task | Best Format |
|---|---|
| Excel paste (vertical) | Column (newline) |
| Email list | Comma-separated |
| Database import | Tab or pipe |
| Data with commas | Tab or pipe |
| European region | Semicolon |
| Log file output | Tab or pipe |
| API parameter list | Comma-separated |