CSVfox
Leverage Your Data.
 English

±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 (+c=false), empty column names will be written to the output file, if -c=true is enabled.
However, these columns can also be given a name for output, e.g. for the third column using -rename[3]=SomeName .

Per default csvfox is assuming that the first row contains column names in all files (+c=y, -c=y). As a parameter for this setting "y", "yes", "true", or "1" will be accepted, as well as "n", "no", "false", or "0". Upper/Lower case will be ignored.

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.

CSV Table with column Names (Default Mode)

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
SeasonGreenCarDays
springflowersbicycle91
summerfruitscabriolet92
autumncolorful leaveslimousine92
wintersnowy twigssled90

CSV Table without Column Names

csvfox inputfile.csv +c=N
Assumes that the CSV file to read (inputfile.csv) does not have column names in the first row.
When there is really no header line, this behaviour is correct:
inputfile.csv
springflowersbicycle91
summerfruitscabriolet92
autumncolorful leaveslimousine92
wintersnowy twigssled90

However, this will also misinterpret an existing header line to be the first data row:

inputfile.csv
SeasonGreenCarDays
springflowersbicycle91
summerfruitscabriolet92
autumncolorful leaveslimousine92
wintersnowy twigssled90

Removing the Column Names for Output

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
SeasonGreenCarDays
springflowersbicycle91
summerfruitscabriolet92
autumncolorful leaveslimousine92
wintersnowy twigssled90
outputfile.csv
springflowersbicycle91
summerfruitscabriolet92
autumncolorful leaveslimousine92
wintersnowy twigssled90
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.

Introducing Column Names for Output

csvfox inputfile.csv +c=N -c=Y outputfile.csv
Assumes that the CSV file to read (inputfile.csv) has no column names in the first row, while the CSV file to write (outputfile.csv) will have them.
In other words, this invents a header line with empty column names.
inputfile.csv
springflowersbicycle91
summerfruitscabriolet92
autumncolorful leaveslimousine92
wintersnowy twigssled90
outputfile.csv
 
springflowersbicycle91
summerfruitscabriolet92
autumncolorful leaveslimousine92
wintersnowy twigssled90
In this case, the missing column names should be filled in later, using ±rename.
If a CSV file has no column header line and therefore no column names, you obviously cannot access it's fields by name. Addressing of the CSV fields by number [1]-[9],[10]-[99] etc., or in Excel notation [A]-[Z],[AA]-[AZ] etc. is still supported.
Under construction, coming soon