ApexAutomation
Apex Automation

Apex Automation free tools

CSV Splitter

One file per value, and no two values
quietly sharing a file

Splitting a spreadsheet by a column is a solved problem until two of the values come out as the same file name. A slash cannot live in a file name. Windows does not tell USA from usa. The same word can be written two ways in Unicode and look identical on screen. When that happens the rows of one group join the other, the totals still add up, and nothing says a word. This page counts every row out again and names every collision before you download anything.

  • Free to use
  • No account needed
  • Nothing uploaded
  • No row limit

Nothing to hand?

Drop a CSV or Excel file here

or

The columns are read for you. Pick which one to split on, and see how many files it makes before downloading.

What this page will read

  • .csv, .tsv or .xlsxSemicolon, tab and pipe separated too. In a workbook the first sheet holding rows is read, so a cover page in front of it is stepped over.
  • Any number of rowsThere is no cap and no sign up. The work happens on your own machine, so the limit is your machine.
  • Any encodingUTF-8, UTF-16, Windows-1252, with or without a byte order mark. A file that is not UTF-8 is read correctly and named, so an accented value does not arrive broken.
  • Any column, named or notA header row is used when there is one, and columns are numbered when there is not. You pick the column, and you can pick a second one to split by both together.
  • Values in any scriptJapanese, Arabic, Devanagari, Thai. They are kept as they are in the file names, and where two of them are the same text written two ways, that is reported rather than silently merged.
  • Dates in any shapeYear first, day first, month first, a written month name in sixteen languages, or a spreadsheet date serial. Where day and month could swap, the whole column settles it rather than each row guessing.
  • Numbers in any numeral systemArabic-Indic, Devanagari and more than fifty others, for when you split by a number range.
  • Columns you are not splitting onRead past, not used, not changed, and carried into every output file exactly as they were.

What it works out for itself. The number of files before you commit to them, which values would collide as file names, which rows have nothing in that column, and whether a split that makes hundreds of tiny files is really the one you meant.

How to split it

The split can be right and the files still be wrong

Take a column of regions with North/South in it. A file name cannot contain a slash on any operating system, so every tool replaces it with something else, usually a hyphen. If another row says North-South, the two now have the same file name. One of them is written over the other, or the rows are appended together, depending on which tool you used. Either way you end up with one file where you expected two, and the row counts you can see still look perfectly correct.

And a slash is only the most obvious of five.

USA and usa are two values to a spreadsheet and one file to Windows and macOS, because neither tells file names apart by case. Café can be written with one character for the é or with an e followed by a separate accent mark, which look identical on screen and are different strings to a computer, until they reach a file system that joins them. A value ending in a space loses that space the moment it becomes a file name, because Windows strips it. And a value longer than a file name can be gets cut, so two long values that differ only at the end become one.

Every one of those is in the example on this page. A plain split turns fourteen rows into ten files and loses four groups into other groups. This one makes twelve files, and tells you about all four.

What happens instead. The first value keeps its name. The second gets a number added. Nothing is ever written over anything, and the page lists which values collided and which of the five reasons it was.

Every row counted out again

The rule this tool is built on is short enough to check: every row that goes in comes out in exactly one file, and the row counts of all the files add up to the number of rows you started with. Not most rows. Not the ones with values in them. Every row.

That is harder than it sounds, because the usual failures do not break the count. Two groups merging into one file keeps the total the same. Rows with an empty value being dropped is visible only if you were watching the total. So the count is done twice here, by two things that share no code: once by the engine from its own grouping, and once by reading the files that were actually written and counting the rows in them. Both numbers are on the page before you download anything.

When are two values the same thing?

This is the question underneath the whole job, and most tools answer it for you without saying so. Whether UK is the same as uk, whether "North " with a space at the end is the same as "North", whether U.K. is the same as UK: each of those is a real decision with a real consequence. A tool that quietly folds them together gives you one file where you wanted three. A tool that keeps them apart gives you three where you wanted one. Neither is wrong in general and both are wrong sometimes.

So it is a setting, and the default is the safest one: exactly, character for character. Three looser settings are there when you want them, from ignoring spaces at the ends up to ignoring case, spacing, punctuation and accents all at once. Whichever you choose, anything that gets joined together is listed on the page with the values that were joined, so you can see the effect of the setting rather than guess at it.

The files go out in the shape they came in

A file exported from a German or French system is usually semicolon separated, because the comma is the decimal point there. Open a comma separated file in that Excel and every row arrives as a single long cell. It is one of the most common ways a perfectly correct file looks broken to the person who receives it.

So the output here keeps what the input had: the same separator, the same encoding, and the byte order mark if there was one. A tab separated file comes back tab separated. A UTF-16 file comes back UTF-16. You can turn that off and get plain comma separated UTF-8 instead, but it is a choice you make rather than one made for you.

Seven ways to decide what belongs together

Splitting by the value in a column is the common one, and it is not always the useful one. A column of order dates has as many values as rows, so splitting by the value gives you one file per order. Splitting by the month in it gives you twelve.

So the value itself is one of seven. There is the year, the month and the day inside a date, read from whatever shape the date is written in. There is the first letter, for splitting a list of names into an A file and a B file. There is the first few characters, for codes with a meaningful prefix. There is a number range, for putting every total between zero and ninety nine in one file. And there are the two that have nothing to do with the values at all: every so many rows, and into a number of equal parts.

Two columns at once works as well, which gives one file per combination: one per region and status rather than one per region.

What has actually been tested

Every figure here is a test run that has to pass before anything reaches this page. If one fails, nothing ships. A test reads this page, pulls out every figure in it, and compares each one with the code behind it.

283automated checks, all passing
11suites, each runnable on its own
5ways two values become one file, each caught
7ways to decide what belongs together
4settings for when two values are the same thing
0bytes uploaded
The count is done twice, by two things that share no code Once by the engine from its own grouping, and once by opening the zip, reading every file out of it and counting the rows. If those two ever disagree, something went wrong that a single count would not have shown.
A thousand values that all collide still make a thousand files The worst case for a name collision is every value colliding with every other. That is a test here, and the answer has to be a thousand distinct files with every row in exactly one of them.

Properties you can hold it to

Questions people ask first

What happens when two different values would make the same file name?

They are kept apart and you are told. A file name cannot hold a slash, so North/South and North-South come out the same. Windows and macOS do not tell USA and usa apart. The same word can be written two ways in Unicode and look identical. A space at the end of a value disappears. Every one of those turns two groups into one file in a plain split, and the rows of one quietly join the other. Here the second group gets a number added to its name, and the page says which values collided and why.

Where do rows with nothing in that column go?

Into a file of their own, called (blank) unless you name it something else. They are not dropped and they are not put into whichever group happens to be first. The page counts them and tells you how many there were, because a column that is empty in a tenth of the rows is usually worth knowing about before you send the files on.

Is my file sent anywhere?

No. The file is read inside this browser tab and the split happens there too. There is no upload endpoint and no server to receive anything. You can disconnect after the page has loaded and carry on working, which a test does on every run. Nothing is stored either, so closing the tab leaves nothing behind.

Will the output files still open properly in my Excel?

By default the files keep the shape the original arrived with: the same separator, the same encoding, and the byte order mark if it had one. That matters because a file that came in semicolon separated and goes out comma separated opens as one long column in a lot of European Excel installations. You can turn that off and get plain comma separated UTF-8 instead.

The column I picked has thousands of different values in it.

You get thousands of files, which is almost never what you want. The page tells you how many files a split will make before you download anything, and says so plainly when the number looks like the column holds something close to unique, such as an email or an id. You can also put every group below a size you choose into one file instead.

Can I split by two columns at once?

Yes. Pick a second column and you get one file per combination rather than one per value: one file for North and open, another for North and closed, and so on. The file name carries both values. Everything else behaves the same way, including the collision checking, which matters more with two columns because there are more names to collide.

My dates are written day first and the tool needs to know.

It works it out from the column rather than from each row. If any row in the column has a first number above twelve, the whole column must be day first, and every row is read that way. If nothing in the column settles it, the page says so rather than picking one and being three weeks wrong on some of the rows. Written month names are read too, in sixteen languages, and so are spreadsheet date serials.

Does the header row go on every file?

Yes, when the input had one. There is a checkbox for files that do not, and then the first row is treated as data and no header is written. Either way the columns you are not splitting on are carried through exactly as they were, including the ones the tool never looks at.

Tell us what would make this better

A file this page splits wrongly is the most useful thing anyone can send us. Take the real values out first, the shape is enough. toolssupport@apexautomationteam.com

  • A way of grouping that is not here yet
  • A file whose separator or encoding was read wrongly
  • A collision this page did not notice
  • A version of this wired into your own system
  • Something else altogether, built to your spec

Email our team See the other free tools

This page is a tool, not advice about your data. Check the output before you send it on.