comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: read_ascii for many rows / possible to create automatic names for variables
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: read_ascii for many rows / possible to create automatic names for variables [message #57940 is a reply to message #57153] Sat, 05 January 2008 07:56 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Britta writes:

> 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?

Ah, yes. Well, you need a doctor. You have come to the
right place if you want a loopy one. :-)

> Where do i have to use the indices for the
> different files?

The best thing for you to do is to probably learn
how to put a breakpoint in your code so you can
walk through it a couple of times, understanding
how it works. Once you do that, I can't imagine
you ever having trouble with loop indices again.
It might help to have a piece of paper and a pencil
handy, as well as a clear idea of what it is you
*expect* the program to do.


> ###############################
>
> 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)

Your immediate problem is here. The purpose of the line above
is to find out how many rows there are in the file you are
about to read. You have passed it the whole list of files.
Naturally, FILE_LINES is confused. :-)

Since files is a long list, and since you are doing this
is a loop, with the index I, you will want to subscript this
list with the index in order to find the right file:

rows = File_Lines(files[I])

Or, if I wanted this code to be even clearer, I might write
something like this:

FOR j=0,nfiles-1 to BEGIN
thisfile = files[j]
rows = File_Lines(thisfile)

It is not clear to me from your code what you expect to do
with this data you are collecting from all these files,
but perhaps we can solve that problem later. :-)

Cheers,

David
--
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.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: array operations and memory consumption
Next Topic: pson + !p.multi + xyouts

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 15:26:48 PDT 2025

Total time taken to generate the page: 0.08046 seconds