cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to load a q-script from the internet without saving it at disk?

vivo
New Contributor II

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?

1 ACCEPTED SOLUTION

davidcrossey
Moderator Moderator
Moderator

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

David

View solution in original post

1 REPLY 1

davidcrossey
Moderator Moderator
Moderator

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

David