csv:parse header option not working in version 11.7

Wednesday, 19 March 2025 · 5 messages · last reply 20 Mar 2025
LV
Lizzi, Vincent19 Mar 2025 20:39 #
Hi BaseX team, Has the "header" option on csv:parse changed between BaseX version 11.6 and 11.7? Here is an example to illustrate what looks like a problem or change. Given a tab separated text file such as this: aaaa bbbb cccc a1 b1 c1 a2 b2 c2 This query uses the "header": "yes" option on csv:parse which should map column names to element names. "tsv-test.tsv" => file:resolve-path() => file:read-text() => csv:parse(map{'separator': 'tab', 'header': 'yes'}) BaseX version 11.6 produces the expected parse:
<csv>
  <record>
    <aaaa>a1</aaaa>
    <bbbb>b1</bbbb>
    <cccc>c1</cccc>
  </record>
  <record>
    <aaaa>a2</aaaa>
    <bbbb>b2</bbbb>
    <cccc>c2</cccc>
  </record>
</csv>
BaseX version 11.7 seems to be ignoring the header option and produces this output:
<csv>
  <record>
    <entry>aaaa</entry>
    <entry>bbbb</entry>
    <entry>cccc</entry>
  </record>
  <record>
    <entry>a1</entry>
    <entry>b1</entry>
    <entry>c1</entry>
  </record>
  <record>
    <entry>a2</entry>
    <entry>b2</entry>
    <entry>c2</entry>
  </record>
</csv>
If this is an expected change, is there any equivalent to the option "header": "yes" ? Best regards, Vincent ______________________________________________ Vincent M. Lizzi Head of Information Standards | Taylor & Francis Group E-Mail: vincent.lizzi at taylorandfrancis.com<mailto:vincent.lizzi at taylorandfrancis.com> Web: www.tandfonline.com<http://www.tandfonline.com/> Time zone: US Eastern Taylor & Francis is a trading name of Informa UK Limited, registered in England under no. 1072954 "Everything should be made as simple as possible, but not simpler." Information Classification: General
MH
Martin Honnen19 Mar 2025 21:35 #
Quoted text · Vincent · 23 lines
On 19/03/2025 20:39, Lizzi, Vincent wrote: > > Hi BaseX team, > > Has the “header” option on csv:parse changed between BaseX version > 11.6 and 11.7? > > Here is an example to illustrate what looks like a problem or change. > Given a tab separated text file such as this: > > aaaa bbbb cccc > > a1 b1 c1 > > a2 b2 c2 > > This query uses the “header”: “yes” option on csv:parse which should > map column names to element names. > > "tsv-test.tsv" => file:resolve-path() => file:read-text() => > > csv:parse(map{'separator': 'tab', 'header': 'yes'}) >
With some tries (at https://martin-honnen.github.io/cheerpj-basex-test/, shameless plug) I have found that 'header' : true() e.g.
   csv:parse(map{'separator': '&#9;', 'header': true()})
works in 11.7. No idea whether that is an intended change but perhaps you can adapt your code.
MH
Martin Honnen19 Mar 2025 21:41 #
Quoted text · Martin Honnen · 3 lines
On 19/03/2025 21:35, Martin Honnen via BaseX-Talk wrote: > No idea whether that is an intended change but perhaps you can adapt > your code.
https://github.com/BaseXdb/basex/pull/2376 suggests it was considered a harmful change that has been fixed so in upcoming releases you should be able to use 'yes` again.
GR
Gunther Rademacherin reply to Martin Honnen, 19 Mar 2025, 21:3519 Mar 2025 21:50 #
Hi Martin, sorry about that. CSV functionality had been worked on to integrate the new XQuery 4.0 CSV functions, and this change of behaviour had inadvertently slipped into 11.7. However the problem has been fixed recently, and the fix will go into 11.8. See https://github.com/BaseXdb/basex/pull/2376 for the details. Best regards, Gunther Gesendet: Mittwoch, 19. März 2025 um 21:35
Quoted text · Martin Honnen · 38 lines
Von: "Martin Honnen via BaseX-Talk" <basex-talk at mailman.uni-konstanz.de> An: basex-talk at mailman.uni-konstanz.de Betreff: [basex-talk] Re: csv:parse header option not working in version 11.7 On 19/03/2025 20:39, Lizzi, Vincent wrote: > Hi BaseX team, > > > > Has the “header” option on csv:parse changed between BaseX version 11.6 and 11.7? > > > > Here is an example to illustrate what looks like a problem or change. Given a tab separated text file such as this: > > > > aaaa bbbb cccc > > a1 b1 c1 > > a2 b2 c2 > > > > This query uses the “header”: “yes” option on csv:parse which should map column names to element names. > > > > "tsv-test.tsv" => file:resolve-path() => file:read-text() => > > csv:parse(map{'separator': 'tab', 'header': 'yes'}) With some tries (at https://martin-honnen.github.io/cheerpj-basex-test/, shameless plug) I have found that 'header' : true() e.g. csv:parse(map{'separator': '&#9;', 'header': true()}) works in 11.7. No idea whether that is an intended change but perhaps you can adapt your code. > > >
LV
Lizzi, Vincent20 Mar 2025 03:51 #
Hi Gunther and Martin, Thank you for the quick responses! After updating to use true() in place of 'yes', csv:parse is now working again. Best regards, Vincent _____________________________________________ Vincent M. Lizzi Head of Information Standards | Taylor & Francis Group vincent.lizzi at taylorandfrancis.com<mailto:vincent.lizzi at taylorandfrancis.com> Information Classification: General
Quoted text · Gunther Rademacher · 29 lines
From: Gunther Rademacher via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Sent: Wednesday, March 19, 2025 4:51 PM To: martin.honnen at gmx.de; basex-talk at mailman.uni-konstanz.de Subject: [basex-talk] Re: csv:parse header option not working in version 11.7 Hi Martin, sorry about that. CSV functionality had been worked on to integrate the new XQuery 4.0 CSV functions, and this change of behaviour had inadvertently slipped into 11.7. However the problem has been fixed recently, and the fix will go into 11.8. See https://github.com/BaseXdb/basex/pull/2376<https://github.com/BaseXdb/basex/pull/2376> for the details. Best regards, Gunther Gesendet: Mittwoch, 19. März 2025 um 21:35 Von: "Martin Honnen via BaseX-Talk" <basex-talk at mailman.uni-konstanz.de<mailto:basex-talk at mailman.uni-konstanz.de>> An: basex-talk at mailman.uni-konstanz.de<mailto:basex-talk at mailman.uni-konstanz.de> Betreff: [basex-talk] Re: csv:parse header option not working in version 11.7 On 19/03/2025 20:39, Lizzi, Vincent wrote: Hi BaseX team, Has the "header" option on csv:parse changed between BaseX version 11.6 and 11.7? Here is an example to illustrate what looks like a problem or change. Given a tab separated text file such as this: aaaa bbbb cccc a1 b1 c1 a2 b2 c2 This query uses the "header": "yes" option on csv:parse which should map column names to element names. "tsv-test.tsv" => file:resolve-path() => file:read-text() => csv:parse(map{'separator': 'tab', 'header': 'yes'}) With some tries (at https://martin-honnen.github.io/cheerpj-basex-test/<https://martin-honnen.github.io/cheerpj-basex-test>, shameless plug) I have found that 'header' : true() e.g. csv:parse(map{'separator': '&#9;', 'header': true()}) works in 11.7. No idea whether that is an intended change but perhaps you can adapt your code.

⚡Generated with XQuery