I am using Octave 4.0.0 on Windows and have problems when using textscan
on text data downloaded from the internet. These data have the following format on the internet:
quote_date;paper;exch;open;high;low;close;volume;value
20150605;OTS;Oslo Børs;5.88;5.88;5.88;5.88;5000;29400
20150604;OTS;Oslo Børs;5.50;5.50;5.50;5.50;3728;20504
20150603;OTS;Oslo Børs;5.69;5.70;5.69;5.70;1000;5694
20150601;OTS;Oslo Børs;5.40;5.73;5.30;5.73;4575;24633
20150529;OTS;Oslo Børs;5.40;5.40;5.39;5.40;20197;109033
I am not shure what the end-of-line charachter is in the original data set, but when I copy and paste them into 'Notepad+' the end-of-line characters are CR,LF.
Below I use urlread
to read the data from the url address a
into a string x
:
a = 'http://www.netfonds.no/quotes/paperhistory.php?paper=OTS.OSE&csv_format=sdv';
x = urlread(a);
Then I want to use textscan
to convert the string x
into a vector with header strings and a data vector per header string.
The conversion into a vector with header strings goes well
h = textscan(x,['%s %s %s %s %s %s %s %s %s'],1,'delimiter',';');
This produces a cell array with the nine header text strings, as I wanted. However, when trying to read the rest of the data (skipping the first header line) with the following code:
y = textscan(x,'%d %s %s %f %f %f %f %d %d','headerlines',1,'delimiter',';');
I get this warning from Octave:
>> y = textscan(x,'%d %s %s %f %f %f %f %d %d','headerlines',1,'delimiter',';');
warning: textscan: 'headerlines' ignored when reading from strings
warning: called from
textscan at line 181 column 7
warning: strread: unknown property 'headerlines'
So textscan
does not understand headerlines
. This applies whether I write headerlines
, Headerlines
, or HeaderLines
.
Why doesn't textscan
understand the property headerlines
even thought this property is defined in the textscan
help menu?