±comments
Defining which CSV lines or rows are interpreted as comment lines
Description
Only for CSV or TEXT files.
Generally, CSV or TEXT files do not know "comments". A standard format of comment lines is not provided.
However, in practice comment lines are frequently used. They are usually denoted with a special beginning, often with the character "#".
This command allows defining of a line start character or a line start string which, when used, lets the respective line be interpreted as a comment line.
Whether this option can be used, and which start string must be defined, depends on the providing or consuming application.
Pattern
Handling of comment lines
When CSVfox reads and identifies a comment line, no data processing is done on it. Such comment lines are instead stored for output without their comments marker. If a marker is not also defined for output comments, they are lost.
However when there is also an output comments marker defined, this new marker will be prepended to the comment lines before output, replacing the comments marker from input.
So in order not to sort out the comment lines while passing through CSVfox, both an input and an output ±comments command is required.
Usage Examples
- csvfox infile.csv +comments=# outfile.csv
- Assumes that the CSV file to read has comment lines that start with "#". These comments will be ignored and lost, because there is no definition for comments output.
- csvfox infile.csv +comments=##\s -comments=/** outfile.csv
- Reads infile.csv, which may contain comment lines that start with "## ". Then outputs all data rows unchanged into outfile.csv, while precede each comment line that was previously read with a new start marker "/**" for output.