Cookbook: Difference between revisions

Jump to navigation Jump to search
113 bytes added ,  21 September 2012
Line 209: Line 209:
===Load comma separated values (*.csv) files===
===Load comma separated values (*.csv) files===


A=textread("file.csv", "%d", "delimiter", ",");
{{Code|Load comma separated values files|<syntaxhighlight lang="octave" style="font-size:13px">
B=textread("file.csv", "%s", "delimiter", ",");
A=textread("file.csv", "%d", "delimiter", ",");
inds = isnan(A);
B=textread("file.csv", "%s", "delimiter", ",");
B(!inds) = num2cell(A(!inds))
inds = isnan(A);
B(!inds) = num2cell(A(!inds))
</syntaxhighlight>}}


This gets you a 1 column cell array. You can reshape it to the original size by using the <code>reshape</code> function
This gets you a 1 column cell array. You can reshape it to the original size by using the <code>reshape</code> function


The next version of octave (3.6) implements the <code>CollectOutput</code> switch as seen in example 8 here:                    http://www.mathworks.com/help/techdoc/ref/textscan.html
The next version of octave (3.6) implements the <code>CollectOutput</code> switch as seen in example 8 here:                    http://www.mathworks.com/help/techdoc/ref/textscan.html
657

edits

Navigation menu