SmartQueryTools

Bin Column in CSV Files Online

Bucket a numeric column in CSV files into labelled ranges — equal-width bins or custom edges. Runs entirely in your browser.

How to bin Column in CSV files

  1. Drop your file. The first numeric column is preselected, and the new column name defaults to its name plus _bin.
  2. Pick the column to bin. Only numeric columns are listed.
  3. Choose Equal-width bins and set how many (2 to 50, default 5), or choose Custom edges and type the break points separated by commas, without thousands separators.
  4. Choose Add as new column or Replace column, then click Bin column.
  5. Check the labels in the preview and download the file in the same format.

Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.

Worked example

A food delivery service wants to report how many orders arrived within 30 minutes, within an hour, within two hours, and later than that.

Input (CSV)

order_ref,zone,delivery_minutes
D-8812,Northside,22
D-8813,Harbour,45
D-8814,Northside,60
D-8815,Airport,135
D-8816,Harbour,30

Settings

  • Column to bin: delivery_minutes
  • Binning mode: Custom edges
  • Edge values: 0, 30, 60, 120
  • New column name: delivery_minutes_bin
  • Output: Add as new column

Result

order_refzonedelivery_minutesdelivery_minutes_bin
D-8812Northside22< 30
D-8813Harbour4530 – 60
D-8814Northside6060 – 120
D-8815Airport135≥ 120
D-8816Harbour3030 – 60

Each range includes its lower edge and excludes its upper edge, so 30 falls in "30 – 60" and 60 in "60 – 120". Everything below the second edge is labelled "< 30", and the first edge, 0, does not appear in any label. Values at or above the last edge share "≥ 120". The labels are text, ready for Count by value.

Working with CSV files

The column list only includes columns the reader loaded as numbers. One stray "n/a", "-" or "45 min" in a CSV column makes it text, and it will not be listed. Clean those values with Find and Replace or convert the column with Cast Column Types, then load the cleaned file. Empty fields load as NULL and stay empty in the label column, so they never inflate the top range.

The labels use an en dash and the ≥ sign, and the CSV is written as UTF-8. Programs that read it as UTF-8 show the labels correctly. Excel may show them as garbled characters such as ≥ when you open the file with a double-click. Import it through Data > From Text/CSV with UTF-8 selected instead. Labels never contain commas, so they are written without quotes. With Replace column the numeric column is removed and the label column is written as the last column of the CSV.

Frequently Asked Questions

Why is my number column missing from the list?

It was loaded as text because at least one value is not a plain number, such as "n/a", "-" or "45 min". Clean it with Find and Replace or Cast Column Types, then bin the cleaned file.

Why do the labels look garbled when I open the CSV in Excel?

The ≥ sign and the en dash are UTF-8 characters, and Excel sometimes opens a CSV in the local ANSI encoding. Use Data > From Text/CSV and choose UTF-8, or convert the CSV to Excel first.

Why does equal-width binning give me one more label than the number of bins?

The last edge is the column maximum, and values at or above the last edge get their own "≥" label. With 5 bins on values from 0 to 100 the labels are < 20, 20 – 40, 40 – 60, 60 – 80, 80 – 100 and ≥ 100, and only the maximum lands in the last one. For exactly N groups, use custom edges and put the last edge above the maximum.

What happens to empty values?

They stay empty. A NULL number gets a NULL label, so it is not counted in any range. Use Fill Nulls first if you want them in a range of their own.

How do I sort the bin labels in the right order?

The labels are text, so a plain sort puts "100 – 200" before "30 – 60". Sort by the original numeric column instead. Choosing Add as new column keeps that column in the file.

Related Tools