help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Specific fixed width question...


From: Francesco Potortì
Subject: Re: Specific fixed width question...
Date: Fri, 17 Sep 2010 23:34:40 +0200

>> sscanf can extract formatted text well. e.g.:
>> 
>> sscanf("WA 053 011 Clark County             45","%*2c %*3d %3d %*25c %d")
>> sscanf("WA 053 027 Grays Harbor County      100,"%*2c %*3d %3d %*25c %d")
>> 
>> You can use fscanf to read the whole file:
>> 
>> fid = fopen("data.txt") ;
>> data = fscanf(fid,"%*2c %*3d %3d %*25c %d\n",[2,inf]) ;
>> fclose(fid) ;
>> cntys = data(1,:).' ;
>> data = data(2,:).' ;
>
>This works, but I find it hard to generalize.

Why hard?  Fixed-format is just a work for fscanf.  What do you find
hard? 

-- 
Francesco Potortì (ricercatore)        Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR          Fax:   +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa         Email: address@hidden
(entrance 20, 1st floor, room C71)     Web:   http://fly.isti.cnr.it/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]