Re: read_ascii for many rows / possible to create automatic names for variables [message #57941 is a reply to message #57199] |
Sat, 05 January 2008 07:27   |
britta.mey
Messages: 14 Registered: August 2007
|
Junior Member |
|
|
On Dec 6 2007, 4:10 pm, David Fanning <n...@dfanning.com> wrote:
> Mike writes:
>> I don't think this one will need regexps (although if you are entering
>> a Buddhist monastery, a good foundation in regexps will help your
>> meditation practice tremendously!). If no pattern is passed to
>> strsplit, it splits on whitespace (runs of spaces or tabs). So
>> strsplit(line, /extract) aught to do it.
>
> Oh, that's helpful. I would have read the documentation,
> but, well, you know.
>
> Cheers,
>
> David
>
> P.S. I think you are right about that meditation practice! :-)
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Hello,
a Happy New Year and a new question concerning this stuff. I'd like to
use a for loop to use this routine for many files of the same type,
but i end alway up in errors (loops are really one of my
infirmnesses).
How can i deal with this? Where do i have to use the indices for the
different files?
###############################
files = FILE_SEARCH('E:\Dissertation\field_campaigns
\Megacities07\spectrometer
\Megacities07_2\PC1_VIS_VN3_VN1\cosinus_vn1\90\normal\VISA-
CH2_VIS2\ALBEDO*.dat',count=nfiles)
files_dif= FILE_SEARCH('E:\Dissertation\field_campaigns
\Megacities07\spectrometer
\Megacities07_2\PC1_VIS_VN3_VN1\cosinus_vn1\90\dark\VISA-
CH2_VIS2\ALBEDO*.dat',count=nfiles_dif)
for i=0,nfiles-1 do begin
rows = File_Lines(files)
Openr, lun, files(i), /Get_Lun
line = ""
ReadF, lun, line
parts = StrSplit(line, '[ ' + String(9B) + ']+', /REGEX, /EXTRACT)
cols = N_Elements(parts)
Point_lun, lun, 0
data = FltArr(cols, rows)
ReadF, lun, data
Free_Lun, lun
colMeans = Total(data, 2)/rows
dir(1,i,l)=colMeans[4:n_pixel+3]
endfor
##################################################
At the moment i get an error message for line "data=FltArr(cols,rows)"
-> FLTARR: Expression must be a scalar or 1 element array in this
context: ROWS.
Cheers,
Britta
|
|
|