How to select certain rows out of a file? THX A LOT! [message #76970] |
Wed, 20 July 2011 10:57  |
Tianyi Luo
Messages: 1 Registered: July 2011
|
Junior Member |
|
|
Hi everyone,
I have a txt file which contains 900 rows of data, and in each row the
amount of values is not exactly the same. Now what I wanna do is to
select certain rows, say from the 90th to the 180th, and then try to
find a value out of the rows by a given index. Thank you guys!
Best regards
Tianyi Luo
|
|
|
Re: How to select certain rows out of a file? THX A LOT! [message #77054 is a reply to message #76970] |
Thu, 21 July 2011 10:38  |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
On Jul 20, 1:57 pm, Tianyi Luo <tianyi.tu...@gmail.com> wrote:
> Hi everyone,
>
> I have a txt file which contains 900 rows of data, and in each row the
> amount of values is not exactly the same. Now what I wanna do is to
> select certain rows, say from the 90th to the 180th, and then try to
> find a value out of the rows by a given index. Thank you guys!
>
Hi,
I think your best best is to read the entire data set into a text
vector, then parse the individual lines as needed. I haven't tested
this but something like...
file = "mytext.txt"
nLines = FILE_LINES(file)
x = STRARR(nLINES)
OPENR, lun, file, /GET_LUN
READF, lun, x
FREE_LUN, lun
Now you can use STRSPLIT and friends to manage each of the lines you
are interested in.
Cheers,
Ben
|
|
|