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

Home » Public Forums » archive » Open text files consecutively without knowing names
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: Open text files consecutively without knowing names [message #85265 is a reply to message #85264] Fri, 19 July 2013 09:42 Go to previous messageGo to previous message
John Correira is currently offline  John Correira
Messages: 25
Registered: August 2011
Junior Member
On 07/19/2013 12:22 PM, Morgan Silverman wrote:
> Hello, I have several folders containing ascii files in each. The
> filenames within those folders are a grouping of numbers and letters
> corresponding to year, day, and other instrument characteristics (e.g
> 8358d47a.tps, 8358h41a.tps, 8358l35a.tps). Unfortunately there isn't a
> pattern or order to the filenames beyond the first couple digits which
> are connecting to the parent directory to easily open the files
> consecutively. I want to open each file, read the data, then close and
> repeat on the next file. Is there a way to loop through the files in
> each directory without knowing specifically what the filenames are?
> I'm struggling with how to do this since. Thank you. Sincerely, Morgan


Should be something like this:

files = file_search('/path/to/your/files/','*.tps', COUNT=nfiles)

for i=0, nfiles-1 do begin

nlines = FILE_LINES(files[i])
data = STRARR(nlines)
OPENR, lunit, files[i], /get_lun
READF, lunit, data
CLOSE, lunit
FREE_LUN, lunit

; Do some stuff here

endfor
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: SVDC did not converge
Next Topic: Help with IDLnetURL

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

Current Time: Wed Oct 08 20:05:08 PDT 2025

Total time taken to generate the page: 0.00377 seconds