Re: Importing Data
- From: "Chad " <csh_remove_this@xxxxxxxxx>
- Date: Thu, 8 Jan 2009 19:14:02 +0000 (UTC)
"us " <us@xxxxxxxxxxxxxxx> wrote in message <gk4ob9$mvc$1@xxxxxxxxxxxxxxxxxx>...
"Chad "
I'm relatively new to importing data from the internet. I'm trying to sim=plify importing this dataset:http://data.giss.nasa.gov/gistemp/tabledata/GL=
B.Ts.txt
Sorry. Should have specified. I just need the 12 numerical values for each month in each row...
one of the solutions is outlined below
% the data
url='http://data.giss.nasa.gov/gistemp/tabledata/GLB.Ts.txt';
% the engine
fmt='%4d';
u=urlread(url);
s=strread(u,'%s','delimiter','','whitespace','');
ix=cellfun(@(x) ~isempty(sscanf(x(1:min([4,numel(x)])),fmt)),s);
s=regexprep(s(ix),'(*)+',' nan');
s=cellfun(@(x) sscanf(x,'%g').',s,'uni',false);
s=cat(1,s{:});
% the result (the last few entries only)
disp('some original data');
disp(u(13740:end));
disp('some extracted data');
disp(s(end-4:end,:));
us
Thank you very much us! Your code worked perfectly. I had found a solution, but mine crashed when it get's to 2008 cause December's data point isn't a number (I was using str2num). Thank you again.
.
- References:
- Importing Data
- From: Chad
- Re: Importing Data
- From: NZTideMan
- Re: Importing Data
- From: us
- Re: Importing Data
- From: Chad
- Re: Importing Data
- From: us
- Importing Data
- Prev by Date: Re: multiple tries Metropolis-Hastings produce very different distributions
- Next by Date: Re: Old bug in corrcoef not yet fixed
- Previous by thread: Re: Importing Data
- Next by thread: Re: Importing Data
- Index(es):
Relevant Pages
|