|Subject:||Re: Help me to extract the part of Text file to another format|
|Date:||Sat, 12 Mar 2016 15:59:29 -0500|
On Mar 12, 2016 10:03 AM, "mjayiitk2013" <address@hidden> wrote:
> Hi all,
> I have a text file 40%ROL~1.TXT
> <http://octave.1599824.n4.nabble.com/file/n4675435/40%25ROL%7E1.TXT> who
> has pattern of this kind
> info info info
> info X X X
> offset 0
> 1 344
> 2 43432
> 4 34234
> 3 4323
> offset 0
> 1 3441
> 2 43431
> 4 34231
> 3 4321
> I want to extract the second column between "offset 0" to "X-Ray" in a row
> then another piece in another row
> 344 43432 34234 4323
> 3441 43431 34231 4321
> I have similar files a lot so i want to change all in this manner
> Please guide me to make a script for it
> View this message in context: http://octave.1599824.n4.nabble.com/Help-me-to-extract-the-part-of-Text-file-to-another-format-tp4675435.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> Help-octave mailing list
Okay, I used to do this kind of stuff all the time with octave. I have found that the easiest way is to use the fgetl command. "help fgetl" will get you the syntax. I'm not at my computer right now to give you actual code snippets.
Fgetl will read in one line. You can put it inside a while loop that doesn't end until it hits the end of the file (the read data will give EOF).
Inside of this while loop , you can use the strcmp command to check whether or not you hit the offset 0 line. Then if it matches, read the next series of data until it gives the X-ray line, processing that data as you go along. Continue until the end of the file , picking up each section as you go.
|[Prev in Thread]||Current Thread||[Next in Thread]|