Re: Breaking files [message #70879 is a reply to message #70875] |
Thu, 13 May 2010 17:21   |
Gray
Messages: 253 Registered: February 2010
|
Senior Member |
|
|
On May 13, 5:05 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
> Hello,
>
> I have a code that is designed to read and process text files with
> this format:
>
> =xxx
> id = 1
> a = ...
> b = ...
> c = ...
>
> It starts by reading the data in using file_lines and a string array:
>
> infile = '/path/filename'
> n = file_lines(infile)
> data = strarr(n)
> openr, inunit, infile, /get_lun
> readf, inunit, data
>
> ... and ends by exporting stuff to another text file.
>
> Now I need to deal with input text files that have a slightly
> different format:
>
> =xxx
> id = 1
> a = ...
> b = ...
> c = ...
> =xxx
> id = 2
> a = ...
> b = ...
> c = ...
> =xxx
> id = 3
> a = ...
> b = ...
> c = ...
>
> They are just multiple files appended together. I was wondering if
> there is a simple way of breaking this new big file into multiple
> files with the old format so I don't have to change my code
> considerably (maybe using the "=xxx" lines to indicate where each file
> starts).
>
> Sorry if this is too obvious. I'm new to IDL.
>
> Thank you.
You can use WHERE(STREGEX(data_array,'=xxx',/boolean) to pick out
where the breaks are.
|
|
|