±delete
Prevents one or more CSV columns from output
Description
This command ignores columns when reading (when input) or deletes them from output (when writing).
The most simple case is deleting just one unwanted field.
But you can also enter a list of fields to delete. In this case, it will is a comma-separated list of CSV column names (or numbers), and can even include column ranges denoted with a hyphen.
After the delete command, the respective column(s) are no longer accessible for subsequent commands.
Pattern
±delete[Fieldname]
±delete=[Fieldname]
±delete[AField],[AnotherField],...
±delete=[AField],[FirstOfMoreFields]-[LastOfMoreFields],...
Usage examples
This is the input file names.csv.City | FirstName | LastName | Birth | Driver License |
---|---|---|---|---|
Rome | Andrea | Bocelli | 1958 | y |
Los Angeles | Lieutnant | Columbo | 1927 | y |
London | Hercule | Poirot | 1910 | - |
New York | Theodoros | Kojak | 1922 | y |
- csvfox names.csv -delete[FirstName] lastnames.csv
-
This removes the column
FirstName . The resulting CSV table is written to lastnames.csv.lastnames.csv City LastName Birth Driver License Rome Bocelli 1958 y Los Angeles Columbo 1927 y London Poirot 1910 - New York Kojak 1922 y - csvfox names.csv -delete[3],[4] firstnames.csv
- This command removes the third and fourth column (
LastName andBirth ).firstnames.csv City FirstName Driver License Rome Andrea y Los Angeles Lieutnant y London Hercule - New York Theodoros y - csvfox names.csv -delete[FirstName]-[Birth] nonames.csv
- This command removess a range of three columns (
FirstName ,LastName , andBirth ).nonames.csv City Driver License Rome y Los Angeles y London - New York y
Hint
This command is meant for removing one or a few CSV columns.
If you want to rearrange column output completely, or just write only a few of many columns, consider using ±columns instead.