[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Loading ASCII data files quickly
From: |
Prof M. N. Anandaram |
Subject: |
Re: Loading ASCII data files quickly |
Date: |
Thu, 13 Aug 2009 00:03:49 -0700 (PDT) |
Hello:
Ineed help to read a long datafile (produced by fortran) of which the
following is a sample:
Its 5 columns are separated by single spacing but many blanks have minus signs
also!
-----------------------------------------------------
%Model no 1 Age = 0.000 Gyr
% 2482 15 25 210
6.099804898E+10 5.737968142E-11 4.263896084E+03
1.075125032E+03-3.921649350E-09
7.091014190E-01 2.728385055E+33 6.643099358E-03 0.000000000E+00
1.642454464E+00
3.898655209E-01 1.006586011E+00 1.660402559E+08 8.786761647E-01 3.104463343E+03
0.000000000E+00 1.962800000E-02-3.650469325E+07 0.000000000E+00 0.000000000E+00
0.000000000E+00 0.000000000E+00 0.000000000E+00 4.587748349E-03 9.782398920E-03
6.099764772E+10 5.734173867E-11 4.264186105E+03 1.132813429E+03 4.132080236E-09
7.091014190E-01 2.728385055E+33 6.929622832E-03 0.000000000E+00 1.643060192E+00
3.901287825E-01 1.006268590E+00 1.658643758E+08 8.786761647E-01 3.104635028E+03
0.000000000E+00 1.962800000E-02-3.610343816E+07 0.000000000E+00 0.000000000E+00
0.000000000E+00 0.000000000E+00 0.000000000E+00 4.587748349E-03 9.782398920E-03
6.099724280E+10 5.730138513E-11 4.264507760E+03 1.194167602E+03 4.355834394E-09
7.091014190E-01 2.728385055E+33 7.231427131E-03 0.000000000E+00 1.643677166E+00
3.903977435E-01 1.005974269E+00 1.656907498E+08 8.786761647E-01 3.104782331E+03
0.000000000E+00 1.962800000E-02-3.569851372E+07 0.000000000E+00 0.000000000E+00
------------------------------------------------------
When I used the tdmread() program (see far below) on this file it responds by:
>D:\Octave\bin\octave.exe -q "tdmread.m"
parse error near line 1 of file D:\Octave\fgong_l9bi_d_01s_01.m
syntax error
>>> 6.099804898E+10 5.737968142E-11 4.263896084E+03
>>>1.075125032E+03-3.921649350E-09
^
error: evaluating assignment expression near line 1, column 5
error: near line 1 of file `tdmread.m'
>Exit code: 1
Can any one please help ? It is imp that - sign be read with attached number
also.
Anandaram
==========================================================================
----- Original Message ----
From: Matthias Brennwald <address@hidden>
To: address@hidden
Sent: Tuesday, August 11, 2009 2:12:15 AM
Subject: Re: Loading ASCII data files quickly
On Aug 10, 2009, at 6:07 PM, Michael Grossbach wrote:
> function tdm = tdmread(path2tdmfile)
> [fid, msg] = fopen(path2tdmfile, 'r');
> if fid < 3, error(msg), endif
> first = fgetl(fid);
> second = fgetl(fid);
> data = fscanf(fid, '%f%f', Inf)
> tdm = struct('header', {first; second}, 'data', data);
> fclose(fid);
>
> HTH, Michael
_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Re: Loading ASCII data files quickly, Sergei Steshenko, 2009/08/11