2022.07.30 12:57 AM
Currently if I want to import a q-script, e.g. sp.q, from the internet, I need to save it to disk and then load it.
system "wget https://raw.githubusercontent.com/KxSystems/kdb/master/sp.q";
\l sp.q
But if I want to do the \l to the url directly without saving sp.q to disk, it doesn't work:
\l https://raw.githubusercontent.com/KxSystems/kdb/master/sp.q
If I want to import the q-script without saving it, the only way I can do is to parse sp.q paragraph by paragraph manually:
myText:system "curl https://raw.githubusercontent.com/KxSystems/kdb/master/sp.q";
value "" sv myText[til 5]; // import the 1st paragraph
value "" sv myText[5 _ til 10]; // import the 2nd paragraph
Is there a better way to do this?
2022.07.30 11:51 PM
Hi vivo,
To load a q script it needs to be loaded from the local disk.
You could also use .Q.hg to download the file directly into your process with either of the following as examples:
q)"\r\n" vs .Q.hg `:https://raw.githubusercontent.com/KxSystems/kdb/master/sp.q
/or
q)ssr[;"\r\n";""] .Q.hg `:https://raw.githubusercontent.com/KxSystems/kdb/master/sp.q
However with this approach you'd need a lot of customization per code block to execute it locally.
If you are downloading the script to the local q process, why would you not store it on disk anyway? For example, re-loading later instead of multiple downloads.
Kind regards,
David
2022.07.30 11:51 PM
Hi vivo,
To load a q script it needs to be loaded from the local disk.
You could also use .Q.hg to download the file directly into your process with either of the following as examples:
q)"\r\n" vs .Q.hg `:https://raw.githubusercontent.com/KxSystems/kdb/master/sp.q
/or
q)ssr[;"\r\n";""] .Q.hg `:https://raw.githubusercontent.com/KxSystems/kdb/master/sp.q
However with this approach you'd need a lot of customization per code block to execute it locally.
If you are downloading the script to the local q process, why would you not store it on disk anyway? For example, re-loading later instead of multiple downloads.
Kind regards,
David
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.