Re: Help extracting a single column from dat file [message #90899] |
Sat, 09 May 2015 11:04  |
Nikola
Messages: 53 Registered: November 2009
|
Member |
|
|
On Saturday, May 9, 2015 at 9:30:22 AM UTC+1, JRP wrote:
> Hello,
>
> I need help extracting a single column from a sort of organized .dat file...
>
> The .dat files are structured as follows:
>
> Best filter size for grid = 8x 8, sample size = 2 has radius 9
> Best filter size for grid = 8x 8, sample size = 2 has radius 14
> Best filter size for grid = 8x 8, sample size = 3 has radius 19
>
> Hopefully someone can help me?
>
> I created these .dat files by simply copy/pasting some printed lines out of the IDL console. I know now that there would've been a better way to output the required data, but due to the time it takes to run these code I would like to see if there is any method of extracting a single column (In particular I need to extract the very last number, the radius i.e 9, 14, 19...). If there is no way for me to do this I'll just have to run everything again.
>
> Thanks in advance.
something like this will do you do the job:
n = FILE_LINES(filename)
data = INTARR(n)
line = ''
OPENR, un, filename, /get_lun
FOR i = 0, n-1 DO BEGIN
READF, un, line
data[i] = FIX(STRMID(line, 85, 8))
ENDFOR
FREE_LUN, un
I can think of several more elegant ways to do it, but this one is self-explanatory enough that you can easily modify it for other columns.
|
|
|
|