CSV : escape character feature
Thursday, 13 November 2014 · 5 messages · last reply 28 Nov 2014
FE
Fabrice Etanchaud13 Nov 2014 10:34 #
Dear all,
I did not find a way to specify how to escape quotes when importing a csv file with quotes=yes.
Here is an example :
"12345"|"TOTO LE HERO"|"Toto le héro 3 \"A'' LP"|"67"|"8051"|"4000"|"XX"|""|"LU"|""|""|"ITE"|""||"GB"|""|"20.10"
where quotes are escaped with a leading \
(the '' after the A are two single quotes).
But it seems BaseX detects quote quote ("") as escaped quote. Could it be possible to have in the future an option to override the default behavior ?
Best regards,
Fabrice Etanchaud
Questel/Orbit
CG
Christian Grün14 Nov 2014 20:55 #
Hi Fabrice,
I decided to change the default behavior of the BaseX CSV parser: backslashes will now always be treated as esape characters. \r, \n and \t will be encoded as CR, NL, and TAB, and other characters will be returned literally. A new snapshot is online.
Everyone: please report if this new default causes surprises in your setting.
Best,
Christian
Quoted text · Fabrice Etanchaud · 23 lines
On Thu, Nov 13, 2014 at 10:34 AM, Fabrice Etanchaud <fetanchaud at questel.com> wrote: > Dear all, > > I did not find a way to specify how to escape quotes when importing a csv > file with quotes=yes. > > Here is an example : > > "12345"|"TOTO LE HERO"|"Toto le héro 3 \"A'' > LP"|"67"|"8051"|"4000"|"XX"|""|"LU"|""|""|"ITE"|""||"GB"|""|"20.10" > > where quotes are escaped with a leading \ > (the '' after the A are two single quotes). > > But it seems BaseX detects quote quote (“”) as escaped quote. > > Could it be possible to have in the future an option to override the default > behavior ? > > Best regards, > Fabrice Etanchaud > Questel/Orbit
FE
Fabrice Etanchaud15 Nov 2014 21:56 #
Thank you so much Christian !
-----Message d'origine-----
Quoted text · Christian Grün · 33 lines
De : Christian Grün [mailto:christian.gruen at gmail.com] Envoyé : vendredi 14 novembre 2014 20:56 À : Fabrice Etanchaud Cc : basex-talk at mailman.uni-konstanz.de Objet : Re: [basex-talk] CSV : escape character feature Hi Fabrice, I decided to change the default behavior of the BaseX CSV parser: backslashes will now always be treated as esape characters. \r, \n and \t will be encoded as CR, NL, and TAB, and other characters will be returned literally. A new snapshot is online. Everyone: please report if this new default causes surprises in your setting. Best, Christian On Thu, Nov 13, 2014 at 10:34 AM, Fabrice Etanchaud <fetanchaud at questel.com> wrote: > Dear all, > > I did not find a way to specify how to escape quotes when importing a > csv file with quotes=yes. > > Here is an example : > > "12345"|"TOTO LE HERO"|"Toto le héro 3 \"A'' > LP"|"67"|"8051"|"4000"|"XX"|""|"LU"|""|""|"ITE"|""||"GB"|""|"20.10" > > where quotes are escaped with a leading \ (the '' after the A are two > single quotes). > > But it seems BaseX detects quote quote (“”) as escaped quote. > > Could it be possible to have in the future an option to override the > default behavior ? > > Best regards, > Fabrice Etanchaud > Questel/Orbit
CG
Christian Grün28 Nov 2014 01:14 #
Hi Fabrice,
my first escaping solution was a bit shortsighted. I have now added a new BACKSLASHES option, which allows you (and everyone else in this little XQuery world) to explicitly turn on backslash escaping [1]. This works both for parsing and serializing CSV.
The new snapshot is available in appr. 10 minutes.
Have fun,
Christian
[1] http://docs.basex.org/wiki/CSV_Module
Quoted text · Fabrice Etanchaud · 44 lines
On Sat, Nov 15, 2014 at 9:56 PM, Fabrice Etanchaud <fetanchaud at questel.com> wrote: > Thank you so much Christian ! > > -----Message d'origine----- > De : Christian Grün [mailto:christian.gruen at gmail.com] > Envoyé : vendredi 14 novembre 2014 20:56 > À : Fabrice Etanchaud > Cc : basex-talk at mailman.uni-konstanz.de > Objet : Re: [basex-talk] CSV : escape character feature > > Hi Fabrice, > > I decided to change the default behavior of the BaseX CSV parser: > backslashes will now always be treated as esape characters. \r, \n and \t will be encoded as CR, NL, and TAB, and other characters will be returned literally. A new snapshot is online. > > Everyone: please report if this new default causes surprises in your setting. > > Best, > Christian > > > On Thu, Nov 13, 2014 at 10:34 AM, Fabrice Etanchaud <fetanchaud at questel.com> wrote: >> Dear all, >> >> I did not find a way to specify how to escape quotes when importing a >> csv file with quotes=yes. >> >> Here is an example : >> >> "12345"|"TOTO LE HERO"|"Toto le héro 3 \"A'' >> LP"|"67"|"8051"|"4000"|"XX"|""|"LU"|""|""|"ITE"|""||"GB"|""|"20.10" >> >> where quotes are escaped with a leading \ (the '' after the A are two >> single quotes). >> >> But it seems BaseX detects quote quote (“”) as escaped quote. >> >> Could it be possible to have in the future an option to override the >> default behavior ? >> >> Best regards, >> Fabrice Etanchaud >> Questel/Orbit
FE
Fabrice Etanchaud28 Nov 2014 11:24 #
Thank you so much, Christian.
-----Message d'origine-----
Quoted text · Christian Grün · 54 lines
De : Christian Grün [mailto:christian.gruen at gmail.com] Envoyé : vendredi 28 novembre 2014 01:15 À : Fabrice Etanchaud Cc : basex-talk at mailman.uni-konstanz.de Objet : Re: [basex-talk] CSV : escape character feature Hi Fabrice, my first escaping solution was a bit shortsighted. I have now added a new BACKSLASHES option, which allows you (and everyone else in this little XQuery world) to explicitly turn on backslash escaping [1]. This works both for parsing and serializing CSV. The new snapshot is available in appr. 10 minutes. Have fun, Christian [1] http://docs.basex.org/wiki/CSV_Module On Sat, Nov 15, 2014 at 9:56 PM, Fabrice Etanchaud <fetanchaud at questel.com> wrote: > Thank you so much Christian ! > > -----Message d'origine----- > De : Christian Grün [mailto:christian.gruen at gmail.com] > Envoyé : vendredi 14 novembre 2014 20:56 À : Fabrice Etanchaud Cc : > basex-talk at mailman.uni-konstanz.de > Objet : Re: [basex-talk] CSV : escape character feature > > Hi Fabrice, > > I decided to change the default behavior of the BaseX CSV parser: > backslashes will now always be treated as esape characters. \r, \n and \t will be encoded as CR, NL, and TAB, and other characters will be returned literally. A new snapshot is online. > > Everyone: please report if this new default causes surprises in your setting. > > Best, > Christian > > > On Thu, Nov 13, 2014 at 10:34 AM, Fabrice Etanchaud <fetanchaud at questel.com> wrote: >> Dear all, >> >> I did not find a way to specify how to escape quotes when importing a >> csv file with quotes=yes. >> >> Here is an example : >> >> "12345"|"TOTO LE HERO"|"Toto le héro 3 \"A'' >> LP"|"67"|"8051"|"4000"|"XX"|""|"LU"|""|""|"ITE"|""||"GB"|""|"20.10" >> >> where quotes are escaped with a leading \ (the '' after the A are two >> single quotes). >> >> But it seems BaseX detects quote quote (“”) as escaped quote. >> >> Could it be possible to have in the future an option to override the >> default behavior ? >> >> Best regards, >> Fabrice Etanchaud >> Questel/Orbit
Written for BaseX 7.9. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery