Hello,
I am using BaseX 12.0
It seems that the csv:doc(), csv:parse() functions are not respecting the 'field-delimiter': 'tab' parameter. It emits the following error: [csv:parse] The value of 'field-delimiter' is not a single character: 'tab'.
Though the old style parameter is working: 'separator': 'tab'
It is documented here: https://docs.basex.org/main/CSV_Functions#options
Repro is below.
Failing XQuery =============== declare variable $csv_file as xs:string external := 'c:\path\to\input.txt'; declare variable $xml_file as xs:string external := 'c:\path\to\output.xml';
let $input_options := { 'header': false(), 'trim-whitespace': true(), 'field-delimiter': 'tab' } let $output_options := {'indent': 'yes', 'method': 'xml', 'encoding': 'UTF-8'}
return csv:doc($csv_file, $input_options) -> file:write($xml_file, ., $output_options)
Working XQuery =============== declare variable $csv_file as xs:string external := 'c:\path\to\input.txt'; declare variable $xml_file as xs:string external := 'c:\path\to\output.xml';
let $input_options := { 'header': false(), 'trim-whitespace': true(), 'separator': 'tab' } let $output_options := {'indent': 'yes', 'method': 'xml', 'encoding': 'UTF-8'}
return csv:doc($csv_file, $input_options) -> file:write($xml_file, ., $output_options)
Regards, Yitzhak Khabinsky
Thanks, Yitzhak,
We’ll have to update the documentation. It’s probably best to use char('\t') instead of 'tab' in the future, or the ugly '	' alternative.
Hope this helps, Christian
________________________________ Von: Yitzhak Khabinsky via BaseX-Talk basex-talk@mailman.uni-konstanz.de Gesendet: Freitag, 18. Juli 2025 14:06 An: basex-talk@mailman.uni-konstanz.de basex-talk@mailman.uni-konstanz.de Betreff: [basex-talk] csv:doc(), csv:parse() functions are not respecting the 'field-delimiter': 'tab' parameter
Hello,
I am using BaseX 12.0
It seems that the csv:doc(), csv:parse() functions are not respecting the 'field-delimiter': 'tab' parameter. It emits the following error: [csv:parse] The value of 'field-delimiter' is not a single character: 'tab'.
Though the old style parameter is working: 'separator': 'tab'
It is documented here: https://docs.basex.org/main/CSV_Functions#options
Repro is below.
Failing XQuery =============== declare variable $csv_file as xs:string external := 'c:\path\to\input.txt'; declare variable $xml_file as xs:string external := 'c:\path\to\output.xml';
let $input_options := { 'header': false(), 'trim-whitespace': true(), 'field-delimiter': 'tab' } let $output_options := {'indent': 'yes', 'method': 'xml', 'encoding': 'UTF-8'}
return csv:doc($csv_file, $input_options) -> file:write($xml_file, ., $output_options)
Working XQuery =============== declare variable $csv_file as xs:string external := 'c:\path\to\input.txt'; declare variable $xml_file as xs:string external := 'c:\path\to\output.xml';
let $input_options := { 'header': false(), 'trim-whitespace': true(), 'separator': 'tab' } let $output_options := {'indent': 'yes', 'method': 'xml', 'encoding': 'UTF-8'}
return csv:doc($csv_file, $input_options) -> file:write($xml_file, ., $output_options)
Regards, Yitzhak Khabinsky
Mr. Grun,
Based on the suggestion, I tried both of them.
1) 'field-delimiter': '\t' is erroring out [csv:parse] The value of 'field-delimiter' is not a single character: '\t'.
2) 'field-delimiter': '	' is working.
IMHO, it is better to keep the 'tab' parameter like it was before.
Regards, Yitzhak Khabinsky
1) 'field-delimiter': '\t' is erroring out [csv:parse] The value of 'field-delimiter' is not a single character: '\t'.
char('\t') should work; see [1] for more details.
Best, Christian
basex-talk@mailman.uni-konstanz.de