Iquery csv quote character


#1

When I use iquery --format csv+, string types are quoted with '. Is it possible to configure the quote character? I would like to use " instead.


#2

Yes! Use the format string ‘csv+:d’ to force double quotes:

$ iquery --format csv+:d -aq 'scan(B)'
0,0,"Yowza."
1,1,"Yowza."
2,2,"Yowza."
3,3,"Yowza."

The 15.12 documentation for iquery mentions that you can use all the same format modifier options as the save() operator, but the save() operator doc does not mention that ‘d’ can be used to force double quotes (and ‘s’ to force single quotes, should that ever prove necessary). Other available options mostly tailor the display of null values:

  • E – the null value ?0 appears in the TSV or CSV file as an unquoted empty string.
  •     N – the null value ?0 appears in the TSV or CSV file as \N .  This is the default for TSV formats.
    
  •     n – the null value ?0 appears in the TSV or CSV file as the unquoted lowercase token "null".  This is the default for CSV formats.
    
  •     ? – the null value ?0 appears in the TSV or CSV file as ?0
    
  •     l (lowercase L, not a numeral) – the save() operator writes a label line (sometimes called a nameline or header line) before writing the rest of the data. The default behavior is to omit label lines.
    

I notice that iquery has a bug: although you can specify these options on the command line as in the example above, when in interpreter mode you cannot:

$ iquery -a
AFL% set format csv+ ;
AFL% set format csv+:d ;
Unknown command 'set format csv+:d' .
Type 'help;' for iquery internal commands reference.
AFL%

I’ll open a ticket for that.