Change Order of CSV Columns
If you have a CSV file and would like to change the order of columns, simply import it into PowerShell, use Select-Object to change the...
- Written By: ps1
- Last Updated: April 22, 2025
- 2 minutes read
If you have a CSV file and would like to change the order of columns, simply import it into PowerShell, use Select-Object to change the...
If you have a CSV file and would like to change the order of columns, simply import it into PowerShell, use Select-Object to change the order, and then re-export the CSV file again!
$Path = "c:\somepathtocsv.csv" (Import-CSV -Path $Path) | Select-Object -Property Column1, Column3, Column2 | Export-CSV -Path $Path
Note the parenthesis: they allow you to write back to the same file because PowerShell will first read in the CSV completely before it changes data and writes back to the same file.
Try this with some non-productive CSV material first. You may have to add the -Delimiter parameter to the CSV cmdlets if your CSV files are using a delimiter other than a comma.
Contact our sales team to get a personalized demo of our database management software for SQL Server!