±usenull, ±u
Defines whether "null" is supported for file input or output
Description
CSV generally does not support any "null" value. It knows only empty text fields with a length of 0. These may be enclosed in ±quotechar characters, or not. It makes no difference.
But in reality there are applications that require the differentiation between "empty" fields, and "null" fields in their CSV import files.
Null fields are defined to have no value at all, they are not just an empty text field.
When using such an application, there is also already an informal convention for this with CSV: while each "empty" text field with a length of 0 consists of two consecutive ±quotechar characters between the delimiters, "null" fields are not there and not enclosed; they are just identified by two consecutive delimiter characters.
The default value for ±usenull is "no", i.e. this setting is disabled.
Pattern
[
Function
The setting ±usenull=yes changes a few more things:
All newly generated empty fields (using ±add without content specification) will be null instead of empty.
±clear means setting the field(s) to null instead of empty.
Usage Examples
- csvfox infile.csv +d=";" +u (...)
- Assumes that the CSV file to read has semicolon as field delimiter, and differentiates between
...;"";... (empty) and...;;... (null) like above. - csvfox infile.csv -u outfile.csv
- Reads infile.csv (without usenull mode) and writes it into outfile.csv, using usenull mode. However, as there were no null fields detected in the input file, the only effect is that empty fields that were not quoted in the input file are now double-quoted in the output file.
- csvfox infile.csv +d=";" -d=pipe outfile.csv
- [
To replace ] Reads infile.csv with given field delimiter ";", and writes it into outfile.csv, using a pipe ("|") character as field delimiter for writing.
infile.csv:Spring;Summer;Autumn;Winter blossoms;"green leaves";"fruits and nuts";"tiles stove" bicycle;cabrio;pick-up;sledgeoutfile.csv:Spring|Summer|Autumn|Winter blossoms|"green leaves"|"fruits and nuts"|"tiles stove" bicycle|cabrio|pick-up|sledge