CSV Table Transformation on the Command Line (CLI)
Migrate or modify CSV tables on the command line interface
Your versatile command line editing tool for CSV tables!
csvfox oldprices.csv -set[Price]="([Price]+20%)" -columns=Name,Price,VAT newprices.csv
.................................................................
Done.
What is it not?
- It is not a database application. It also does not store neither fetch any data from a database.
- It is not a spreadsheet.
- It is not a statistical or analytical application. It cannot aggregate or segment data.
- It is not an interactive Windows app, but purely a console (command line, PowerShell, batch) tool.
But then, what is it?
Your CSV input file does not fit to what is needed? You have information scattered in various tables but need them in one? You have to change, insert, combine, split, recalc, reformat, reorder fields in your CSV table? And this has to be done on a regular basis without human assistance, reliable and repeatable, without using a database or spreadsheet application, without any manual clicks?
Here comes your tool for all of this.
This program is used like a regular command on the windows command line. It is also suitable for automation, like usage in batch files or PowerShell scripts.It reads CSV tables, changes them in various ways, merges them together or filters them before outputting.
Some Examples:
- csvfox infile.csv +e=utf-8 +d=";" -e=Windows-1252 -d=pipe outfile.csv
- This command changes the format of the CSV file.
It readsinfile.csv
, assuming UTF-8 encoding and semicolon as delimiter. Then it writes the data tooutfile.csv
, while changing delimiters to "|" and the encoding to ANSI (Windows).
See also ±encoding and ±delimiter. - csvfox prices.csv +e=windows-1252 -set[Price]="{([Price]+20%),2}" -e=utf-8 newprices.csv
- This recalculates a numeric field.
It reads the Windows-formatted CSV file "prices.csv", increases the existing CSV columnPrice by 20 percent, and formats the result with decimal comma and two decimal places. Then writes all data out to "newprices.csv" using UTF-8.
See also Calculating with Numeric CSV Fields. - csvfox newprices.csv -add["Special Offer Text"]="Just for you: [Price]!" specialoffers.csv
- This command adds a new column and fills it with text.
It appends the new columnSpecial Offer Text to the CSV table and inserts some text including the contents ofPrice there.
See also Expressions and their Resolving. - csvfox cities.csv %merge[Name]=[Location]@attractions.csv cityattractions.csv
- This example combines two files.
It enriches the data in "cities.csv" with all fields of the attractions listed in "attractions.csv", where the columnLocations in "attractions.csv" matches the fieldName in "cities.csv" . The resulting data will be written to "cityattractions.csv".
See also %merge.