Use CSV Column Selector

Enter your data below to use the CSV Column Selector

📌 Try these examples:
RESULT

Last updated

CSV Column Selection

CSV column selection extracts specific columns from a CSV file, discarding the rest. This is useful when working with large datasets that have many columns but you only need a subset for analysis or import. It's a fundamental data transformation operation in ETL (Extract, Transform, Load) pipelines.

CSV Structure

Text
id,name,email,age,city,country
1,Alice,alice@example.com,30,New York,US
2,Bob,bob@example.com,25,London,UK
3,Carol,carol@example.com,35,Paris,FR

# Select only: id, name, email
id,name,email
1,Alice,alice@example.com
2,Bob,bob@example.com
3,Carol,carol@example.com

Column Selection in JavaScript

JavaScript
function selectCsvColumns(csvText, columns) {
  const lines = csvText.trim().split('
');
  const headers = lines[0].split(',').map(h => h.trim());

  // Find indices of selected columns
  const indices = columns.map(col => {
    const idx = headers.indexOf(col);
    if (idx === -1) throw new Error(`Column not found: ${col}`);
    return idx;
  });

  return lines.map(line => {
    const cells = line.split(',');
    return indices.map(i => cells[i] ?? '').join(',');
  }).join('
');
}

const csv = `id,name,email,age
1,Alice,alice@example.com,30
2,Bob,bob@example.com,25`;
console.log(selectCsvColumns(csv, ['id', 'name']));

Frequently Asked Questions

Simply enter your data, click the process button, and get instant results. All processing happens in your browser for maximum privacy and security.