Swap CSV Columns
Just upload your CSV file in the form below, specify the columns to swap, and the tool will automatically change the positions of the specified columns in the output file. In the tool options, you can specify the column positions or names that you want to swap, as well as fix incomplete data and optionally remove empty records and records that have been commented out.
What is a Swap CSV Columns?
This tool reorganizes CSV data by swapping the positions of its columns. Swapping columns can enhance the readability of a CSV file by placing frequently used data together or in the front for easier data comparison and editing. For example, you can swap the first column with the last or swap the second column with the third. To swap columns based on their positions, select the
Swap CSV Columns Examples
Click to try!
Move the Key Column to the First Position
In this example, we use our CSV column swapping tool to bring the most important information to the first column. As we are planning to go on vacation soon, in the input of the tool, we load data about national parks that include their names and locations. To decide, which is the closest park to us, we need to see the parks location first, therefore, we swap the first and second data columns so that the "location" column is at the beginning of the CSV data.
Swap-From Column
Set Column-From position
Position of the first column you want to swap
Set Column-From Header
Swap-to Column
Set Column-To position
Position of the second column you want to swap
Set Column-To Header
Incomplete Data
Fill with Custom Values
Fill incomplete CSV data with empty symbols or a custom symbol.
Specify a custom symbol to fill incomplete CSV data with
Comments and Empty Lines
if checked, comments given by the following character will be deleted
Do not include empty lines in the output data.
Reorganize Columns in Vitamins CSV
In this example, a lab intern made a mistake and created a corrupted CSV file with mixed-up columns and missing data. To fix the file, we swap the columns based on the headers "Vitamin" and "Function" so that the "Vitamin" column becomes the first in the output data. We also fill the incomplete CSV data by adding a custom asterisk "*" symbol in place of missing values.
Swap-From Column
Set Column-From position
Set Column-From Header
Header of the first column you want to swap.
Swap-to Column
Set Column-To position
Set Column-To Header
Header of the second column you want to swap..
Incomplete Data
Fill with Custom Values
Fill incomplete CSV data with empty symbols or a custom symbol.
Specify a custom symbol to fill incomplete CSV data with
Comments and Empty Lines
if checked, comments given by the following character will be deleted
Do not include empty lines in the output data.
Place Columns Side by Side for Analysis
In this example, we change the order of columns in a CSV dataset to have the columns essential for analysis adjacent to each other. We match the "ScreenSize" column by its name and place it in the second-to-last position "-2". This groups the "ScreenSize" and "Price" columns together, allowing us to easily compare and choose the phone we want to buy. We also remove empty lines and specify that lines starting with the "#" symbol are comments and should be left as is.
Swap-From Column
Set Column-From position
Set Column-From Header
Header of the first column you want to swap.
Swap-to Column
Set Column-To position
Position of the second column you want to swap
Set Column-To Header
Incomplete Data
Fill With Empty Values
Fill incomplete CSV data with empty symbols or a custom symbol.
Comments and Empty Lines
if checked, comments given by the following character will be deleted
Specify the character used to start comments in the input CSV (and if needed remove them via checkbox above)
Do not include empty lines in the output data.
Related tools
- All tools
- CSV Tools
- Convert CSV to JSONConvert CSV data to JSON format.
- Convert CSV to XMLConvert CSV data to XML format.
- Convert CSV Rows to ColumnsConvert CSV rows to columns.
- Convert CSV to TSVConvert CSV data to TSV format.
- Convert CSV to YAMLQuickly convert a CSV file to a YAML file.
- Change CSV SeparatorChange CSV file delimiter
- Find incomplete CSV recordsQuickly find rows and columns in CSV that are missing values.
- Transpose CSVQuickly transpose a CSV file.
- Insert CSV columnsQuickly insert one or more new columns anywhere in a CSV file.
- TSV to JSONConvert TSV to JSON format