Difference between revisions of "Octave/Storage"

From Coder Merlin
(Created page with "== Reading from a Remote URL == We can read the contents of a remote URL using the following command: {{ConsoleLine|octave:17>|s {{Equal}} urlread ("<nowiki>https://www.codermerlin.com/users/john-williams/sample.csv</nowiki>");}} == Reading from a String == We can read the contents of a string using the following command, interpreting each value read as a Double: {{ConsoleLine|octave:18>|A {{Equal}} strread(s, "%n");}} == Appending from a String == We can append the cont...")
 
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
== Reading from a Local File ==
We can read the contents of a local file using the following command:
{{ConsoleLine|octave:16>|s {{Equal}} fileread ("sample.csv");}}
== Reading from a Remote URL ==
== Reading from a Remote URL ==
We can read the contents of a remote URL using the following command:
We can read the contents of a remote URL using the following command:
{{ConsoleLine|octave:17>|s {{Equal}} urlread ("<nowiki>https://www.codermerlin.com/users/john-williams/sample.csv</nowiki>");}}
{{ConsoleLine|octave:17>|s {{Equal}} urlread ("<nowiki>https://www.codermerlin.com/users/john-williams/sample.csv</nowiki>");}}
== Reading from a String ==
== Reading from a String ==
We can read the contents of a string using the following command, interpreting each value read as a Double:
We can read the contents of a string using the following command, interpreting each value read as a Double:
Line 8: Line 12:
We can append the contents of a string to an existing array using the following command:
We can append the contents of a string to an existing array using the following command:
{{ConsoleLine|octave:18>|A {{Equal}} [A; strread(s, "%n")];}}
{{ConsoleLine|octave:18>|A {{Equal}} [A; strread(s, "%n")];}}
{{MerlinMultipageExperienceNavBar}}

Latest revision as of 12:22, 14 April 2022

Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

Reading from a Local File[edit]

We can read the contents of a local file using the following command:

octave:16> s = fileread ("sample.csv");

Reading from a Remote URL[edit]

We can read the contents of a remote URL using the following command:

octave:17> s = urlread ("https://www.codermerlin.com/users/john-williams/sample.csv");

Reading from a String[edit]

We can read the contents of a string using the following command, interpreting each value read as a Double:

octave:18> A = strread(s, "%n");

Appending from a String[edit]

We can append the contents of a string to an existing array using the following command:

octave:18> A = [A; strread(s, "%n")];