When merging CSVs in the browser, handling mismatched columns and quoted cells changes everything. Here's how filetools does it.
Last week we shipped CSV merge/split/transpose tools for filetools, and the most interesting challenge wasn't CSV parsing - it was handling real-world data without a server. Here's how we handle the hard cases.
The Problem:
CSV files in the wild are messy. Columns don't always match. A cell value contains a comma and that comma is quoted. Headers are sometimes case-sensitive, sometimes not. When you build on a server, you can run a fast library and stream the result. In the browser, you have to make your merge operation deterministic from first load.
Our approach:
Column matching: Users specify which columns to merge on (e.g., "id" or "email"). We do a case-insensitive first pass, then check for exact matches. If no match exists, we warn the user and ask them to pick from the detected headers. This upfront clarity saves merge errors later.
Quoted cell handling: We follow RFC 4180 strictly - a quote inside a quoted field is escaped as a double quote. Most CSV parsers get this wrong when they're quick. We use the
csv-parselibrary (MIT) vendored into the site, same way we do with PDF and ZIP libraries.Column order: The merge operation respects column order from the first file, then appends any new columns from subsequent files. This is deterministic and reproducible.
Why this matters for a browser tool:
Server-based CSV tools hide their assumptions - you upload, they merge, you download. If a merge fails, you get an error message and no insight into why. Client-side, the user can see the detected headers, approve or correct them, and re-try immediately. That transparency matters when you're dealing with data that represents real records or transactions.
What shipped this week:
We added merge, split (by row count or column value), transpose, and comparison tools. The same deterministic, transparent approach applies to each one.
Next question: what's the most painful CSV operation that currently requires downloading a tool or writing a script? We're thinking about row-level filtering and conditional formatting next.
Top comments (0)