File reading; beginning read on line 9 of a file

File reading; beginning read on line 9 of a file

Post by Howard Bai » Mon, 02 Aug 2010 05:00:19


Hello,

I am trying to read a text file in Scilab which has a mix of text and
numerical data for the first few lines and then becomes an easily
readable numerical data file after line 9. I do not need any of the
data in lines 1-9. I am trying to avoid specifying the format of the
first 9 lines, which changes depending on the number of channels
recorded, and then looping through and reformatting everything. Is
there a simple way to open a file and advance a set number of lines?
After deleting the first 9 lines, the read command works fine for my
purposes. Any help appreciated.

Regards,

Howard
 
 
 

File reading; beginning read on line 9 of a file

Post by fakeuse » Mon, 02 Aug 2010 07:56:06

In article < XXXX@XXXXX.COM >,


Living in Unix land I would pre-process the file old.data by
tail +10 old.data > new.data
Then read in new.data.

One can do unix like commands while inside scilab, assuming you
have the tail command in your path.
unix_g("tail +10 old.data > new.data");
X = read("new.data",-1,:);

You also might want to play with
[fd, err] = mopen("old.data");
txt=mgetl(fd);
new_data=txt(10:$); // now has the text from new_data
X = evstr(new_data);


--
Steven Bellenot http://www.yqcomputer.com/ ~bellenot
Professor and Associate Chair phone: (850) 644-7405
Department of Mathematics office: 223 Love
Florida State University email: bellenot at math.fsu.edu

 
 
 

File reading; beginning read on line 9 of a file

Post by Howard Bai » Mon, 02 Aug 2010 12:27:20

Professor Bellenot,

Thank you for that tip. I am running Xubuntu so the command works
as tail -n+10...., but it works great and is much simpler than
deleting the first lines in a text editor and it can be automated
through Scilab. Much appreciated.

Regards,

Howard Bailey



>> >>>>Hello, >> >>>>I am trying to read a text file in Scilab which has a mix of text and >>>>numerical data for the first few lines and then becomes an easily >>>>readable numerical data file after line 9. do not need any of the >>>>data in lines 1-9. am trying to avoid specifying the format of the >>>>first 9 lines, which changes depending on the number of channels >>>>recorded, and then looping through and reformatting everything. s >>>>there a simple way to open a file and advance a set number of lines? >>>>After deleting the first 9 lines, the read command works fine for my >>>>purposes. ny help appreciated. >> >>>>Regards, >> >>>>Howard >> >> Living in Unix land I would pre-process the file old.data by >> tail +10 old.>ata > new.d>ta
> Then read in new.da>a.> >
> One can do unix like commands while inside scilab, assuming >ou
> have the tail command in your pa>h.
> unix_g("tail +10 >ld.data > new.>ata");
> X = read("new.d>ta>,-1,:);
>
> You also might want t> play with
> [fd, err] = mop>n("old.data");
> gt;txt=mgetl(fd);
> new_data=txt(10:$); // now has>the text from new_data
> gt;> X > evstr(new_data);
>
> --
> Steven Bellenot > http://www.yqcomputer.com/ ~bellenot
> Professor and Associate >hair phone: (850) 644-7405
> Department of>Mathematics ffice: 223 Love
> Florida State University mail: bellenot at math.fsu.edu
 
 
 

File reading; beginning read on line 9 of a file

Post by Serge Stee » Wed, 18 Aug 2010 16:38:25

Le 31/07/2010 22:00, Howard Bailey a rit :
May be the fscanfMat Scilab function may solve your problem...

Serge Steer
INRIA