Generate CSV with literal "&", not "&"
Thursday, 30 November 2023 · 3 messages · last reply 1 Dec 2023
EK
Eliot Kimber30 Nov 2023 22:53 #
I’m generating CSV data that includes URLs with multiple query parameters, so “&somekey” in them. These get serialized as “&somekey” where I want “&somekey”.
My CSV XML looks like this:
<record>
<AppID>sn_admin_center</AppID>
<DocsURL>=HYPERLINK(https://docs.servicenow.com/csh?topicname=admin-center-intro&version=vancouver)</DocsURL>
</record>I’m then doing:
let $report := csv:serialize($csv, map{})
let $doWrite := file:write('/Users/eliot.kimber/temp/apps-to-topics.csv', $report)To write the CSV file.
The resulting file looks like:
sn_admin_center,”=HYPERLINK(“"https://docs.servicenow.com/csh?topicname=admin-center-intro&version=vancouver”")"
Note that the “&” is still escaped.
Reviewing the docs for the CVS module and the serialize options, I don’t see any option that looks like it would control how escaping is handled.
Is there a way to do what I want?
Thanks,
E.
_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow>
CG
Christian Grün30 Nov 2023 22:59 #
Quoted text · Eliot Kimber · 5 lines
> > Hi Eliot, > let $doWrite := file:write('/Users/eliot.kimber/temp/apps-to-topics.csv', > $report) >
file:write-text should do the job. An alternative is to use the serialization method 'text':file:write($path, $value, map { 'method': 'text })Hope this helps,
Christian
EK
Eliot Kimber1 Dec 2023 17:10 #
file:write-text() did the trick—that did not occur to me at all.
Cheers,
E.
_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow>Quoted text · Christian Grün · 17 lines
From: Christian Grün <christian.gruen at gmail.com> Date: Thursday, November 30, 2023 at 4:00 PM To: Eliot Kimber <eliot.kimber at servicenow.com> Cc: BaseX <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] Generate CSV with literal "&", not "&" [External Email] Hi Eliot,let $doWrite := file:write('/Users/eliot.kimber/temp/apps-to-topics.csv', $report)file:write-text should do the job. An alternative is to use the serialization method 'text':file:write($path, $value, map { 'method': 'text })Hope this helps,Chr i This message needs your attention • Someone new is on this email. Provided by ServiceNow DT (Employee Portal KB0077950) - This banner is visible only to ServiceNow employees.<https://mimecast.com> Hi Eliot, let $doWrite := file:write('/Users/eliot.kimber/temp/apps-to-topics.csv', $report) file:write-text should do the job. An alternative is to use the serialization method 'text': file:write($path, $value, map { 'method': 'text }) Hope this helps, Christian
Written for BaseX 10.7. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery