DEV Community

Cover image for How to Filter CSV Columns Without Writing Code
kandz
kandz

Posted on

How to Filter CSV Columns Without Writing Code

CSV files are everywhere. Export from a database, download from a dashboard, grab from an API — it's always CSV.

The problem: most CSV files have more columns than you need.

You open it in Excel. You scroll. You select columns. You delete. You reorder. You export. Every single time.

Let's fix that.


Understanding CSV Structure

A CSV file is plain text. Each line is a row. Commas separate columns.

name,age,city,salary
John,28,NYC,50000
Jane,32,LA,62000
Enter fullscreen mode Exit fullscreen mode

The first row is the header — it tells you what each column represents. Everything after is data.


The Manual Way (Don't Do This)

  1. Open CSV in spreadsheet app
  2. Find the columns you want
  3. Delete the ones you don't
  4. Reorder if needed
  5. Export
  6. Repeat next time

This works once. It's painful at scale.


The Code Way

Python with pandas:

import pandas as pd

df = pd.read_csv('data.csv')
filtered = df[['name', 'salary']]
filtered.to_csv('filtered.csv', index=False)
Enter fullscreen mode Exit fullscreen mode

JavaScript with PapaParse:

import Papa from 'papaparse';

const result = Papa.parse(csvText, { header: true });
const filtered = result.data.map(row => ({
  name: row.name,
  salary: row.salary
}));
Enter fullscreen mode Exit fullscreen mode

Both work. Both require setup.


The No-Code Way

I built a free CSV Column Filter that runs entirely in your browser.

What it does:

  • Load any CSV file
  • See all columns
  • Select, deselect, and reorder visually
  • Export clean CSV instantly

Why it's useful:

  • No installation
  • No upload (100% client-side)
  • Works with any CSV
  • Fast

Common Gotchas

Issue Fix
Column names with spaces Quote them
Empty cells Watch for column shift
Line endings Handle \r\n vs \n
BOM at start Strip it before parsing

Try It

https://tools.kandz.me/csv-column-filter


What's your CSV workflow? Do you filter columns often? Let me know in the comments.

Top comments (0)