CSVfox
Gets the job done.
 English

Quick Start - the simple way

This program is used like a regular command on the windows CLI (PowerShell, command, batch file). It reads CSV tables, changes them in various ways according to the command-line parameters, merges them together or filters them before outputting.

In short, this is what you need to know for starting:
  • All commands start with a plus sign (+), a minus sign (-), or an percent sign (%).
  • In all commands, the "+" (plus) command prefix stands for reading or processing the input table, and the "-" (minus) prefix will modify the output table. The "%" (percent) prefix has other purposes.
  • Mostly, a command will contain a column name or a list of column names, and/or an "=" (equal sign) followed by an expression or by a list of expressions.
  • Furthermore, the first parameter which does not look like a command denotes the input file, while the last one denotes the output file. (You can override this by declaring the input file and the output file explicitly through "+in=filepath" and/or "-out=filepath".)
  • The CSV data fields can be accessed with their column names in square brackets, like this: [My Field], with their index like [3], or in "Excel style" like [A]. Generally, the contents of the fields in the first data row are interpreted as the column names.
  • Column names can contain spaces, so when accessing them on the command line better enclose them between doublequotes to prevent tearing the commandline parameter apart.

CSV Table Transformation on the CLI

Changing the CSV table format

The following command changes the CSV field delimiter to a different character, from the comma (,) to a semicolon (;).

This is the raw contents of the CSV table "people_comma.csv":

Name,Age,Eye Color,Hair color Anna,27,brown,black Harald,59,grey,blonde; now grey Peter,38,"Left: brown, right: blue",red

Now we will enter this command:
CSVfox people_comma.csv +d=, -d=; people_semicolon.csv

And this will be the resulting CSV table "people_semicolon.csv":
Name;Age;Eye Color;Hair color Anna;27;brown;black Harald;59;grey;"blonde; now grey" Peter;38;Left: brown, right: blue;red

Please see also that, according to the CSV standard, all fields that contain the actual delimiter character will automatically be enclosed with doublequote characters.

Rearranging CSV data fields order

The CSV data fields can be accessed with their field names in square brackets, like this: [My Field] , or with their index like  [3].

People.csv
NameAgeEye ColorHair color
Anna27brownblack
Harald59greyblonde; now grey
Peter38Left: brown, right: bluered

Enumerating the output columns with the "-columns" command will rearrange the columns as defined. Columns not named in this command will be omitted for output.

So, rearranging will be done like this:
CSVfox People.csv -columns=[Name],["Eye Color"],[Age] People_rearr.csv

This will be the resulting CSV table:

People_rearr.csv
NameEye ColorAge
Annabrown27
Haraldgrey59
PeterLeft: brown, right: blue38

 

Recalculating of a CSV data field

This is the table "Articles.csv", a collection of some clothing for sale.

Articles.csv
ArtNoArticle NamePriceSize
348593485Long Sleeve Business Shirt65.00XX
585048534Trousers70.00XL
459845414Business Jacket85.00XL
524525257Fine Leather Shoes235.00EU46

So now the shop will increase all prices by 20 percent.
The new prices shall become inserted with 2 decimal places:
csvfox Articles.csv +set[Price]={([Price]+20%).2} NewPrices.csv

NewPrices.csv
ArtNoArticle NamePriceSize
348593485Long Sleeve Business Shirt78.00XXL
585048534Trousers84.00XL
459845414Business Jacket102.00XL
524525257Fine Leather Shoes282.00EU46

 

Using a "job" file


(missing example)

This works line by line. At first, the header line is read (if it exists), and all field names are detected.
After this, the table rows are read one after each other, and each line will be processed command by command.

The fields can be accessed with their field names in square brackes like this: [My Field], or with their index like [i]. They can be modified, inserted or deleted, renamed, rearranged, or newly calculated.

Additional fields from other tables can be merged, and the whole table can be sliced (reformatted) into newly arranged derived rows.

At last the table will be saved under a new name.

CSVfox is also suitable for automation, like usage in batch files or PowerShell scripts, so it is supposed to run on schedule by an OS, such as Cron or Task Scheduler.
More complex commands or configurations can be combined as a " job " file, for applying and re-use in various situations.

Some more 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 reads infile.csv , assuming UTF-8 encoding and semicolon as delimiter. Then it writes the data to outfile.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 column Price 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 appends a new column and fills it with text. 
It appends the new column Special Offer Text to the CSV table and inserts some text including the contents of Price 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 column Locations in "attractions.csv" matches the field Name in "cities.csv" . The resulting data will be written to "cityattractions.csv".
See also %merge.
Under construction, coming soon