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

Home » Public Forums » archive » can i read multiple files?
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: can i read multiple files? [message #50253 is a reply to message #50196] Thu, 21 September 2006 19:46 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
zircola writes:

> Thanks every one, i am learning a lot, i tried all of them. using file
> search i put all the files in the array but didn't know how to invoke
> it with for loop, i tried like this
>
> file_array=file_search('filepath', '*.dat', count=num_file)
> for i=0,num_file-1 do begin
> file=file_array(i)
>
> openr, lun, /get_lun, file
>
> (read file here)
> free_lun, lun
> (do all the stuffs like plotting etc here)
>
> endfor
>
> is this how i use the file stored in the array?
>
> for the similar named files, the one suggested by paul works
> great,..thanks
> i just hope my question is not so stupid

Humm. Questions are rarely stupid. I think the problem
here is that we are assuming you know a bit more about
this than I suspect you do. Most of the people who come
to IDL come having written some kind of computer program
before. I get the impression you have not. If this is
so, I would HIGHLY recommend Ken Bowman's book _An
Introduction to Programming with IDL_. It's great
for teaching you what a FOR loop is, etc.

You have mostly the right idea here, but I don't think
you have really tried this code out. For example, this
code is not likely to work:

file_array=file_search('filepath', '*.dat', count=num_file)

To see if it worked you could test how many files you found:

IDL> Print, num_file

Or, you could see how big your file_array variable is:

IDL> Help, file_array

The reason it doesn't work is that 'filepath' is not
likely to be the path to YOUR files. Your path is
going to look more like "C:\RSI\ZIRCOLA\DATA" or
"/usr/zircola/data", or something. We can't help you
with this because you haven't told us anything about
what machine you are running IDL on, etc. The syntax
'filepath' is what we refer to as "pseudo code". We
mean you will have to replace that with what is right
for YOUR situation. As a beginning user, it is often
difficult to tell pseudo code from real code.

Then, if you put all your plotting stuff inside the
loop, you are going to have some trouble because
your plots will appear and disappear so fast you
won't be able to enjoy them. You will end up looking
at just the LAST plot. So, typically, you will do all
your file reading, and THEN you will plot your graphics.

I suggest you maybe start with one file, and see if
you can read that and plot it. Once you have that
under your belt you can extend it to more than a
single file. This way you will know which part of
your code works and which part still has problems.

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
Previous Topic: eventlog for iTools
Next Topic: Re: MPFIT for 21st Century

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

Current Time: Sat Oct 11 22:07:30 PDT 2025

Total time taken to generate the page: 0.96211 seconds