±colnames, ±c
Defining whether the csv file has a header line containing the column names
Description
-c Defines whether the first line of the CSV file will be interpreted as containing the column names.+c Sets or inhibits the output if a column header line when writing a CSV file.
If the input file does not contain column names, there will be also no column names written to the output file, even if +c is enabled.
(Todo: maybe just use Column Numbers as names in this case, and let user "rename" the columns?)
Per default csvfox is assuming that the first row contains column names in all files (
Pattern
±c=truthvalue
±colnames=truthvalue
Usage Examples
In the following examples, the column header line will have a colored background. So you can easily see which CSV tables have column names, and which have none.
- csvfox inputfile.csv
- csvfox inputfile.csv -colnames=Yes
- Assumes that the CSV file to read (inputfile.csv) has column names in the first row. This is default behaviour:
inputfile.csv Season Green Car Days spring flowers bicycle 91 summer fruits cabriolet 92 autumn colorful leaves limousine 92 winter snowy twigs sled 90 - csvfox inputfile.csv -c=N
- Assumes that the CSV file to read (inputfile.csv) does not have column names in the first row (this will misinterpret an existing header line to be the first data row!):
inputfile.csv Season Green Car Days spring flowers bicycle 91 summer fruits cabriolet 92 autumn colorful leaves limousine 92 winter snowy twigs sled 90 - csvfox inputfile.csv -c=yes +c=N outputfile.csv
- Assumes that the CSV file to read (inputfile.csv) has column names in the first row, while the CSV file to write (outputfile.csv) will have them omitted.
In other words, this removes the header line with the column names.inputfile.csv Season Green Car Days spring flowers bicycle 91 summer fruits cabriolet 92 autumn colorful leaves limousine 92 winter snowy twigs sled 90
This might be necessary if the target application cannot work with a column header line, or when the output data rows are to be appended to an existing CSV file with identical structure.outputfile.csv spring flowers bicycle 91 summer fruits cabriolet 92 autumn colorful leaves limousine 92 winter snowy twigs sled 90