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 #85266 is a reply to message #85265] Fri, 19 July 2013 10:17 Go to previous messageGo to previous message
morganlsilverman is currently offline  morganlsilverman
Messages: 46
Registered: February 2013
Member
On Friday, July 19, 2013 12:42:05 PM UTC-4, John Correira wrote:
> 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

This is great. Thank you very much.
[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: Fri Oct 10 13:41:18 PDT 2025

Total time taken to generate the page: 1.20478 seconds