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

Home » Public Forums » archive » Lots of 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: Lots of files [message #53134 is a reply to message #53058] Mon, 19 March 2007 04:32 Go to previous message
lasse is currently offline  lasse
Messages: 48
Registered: February 2007
Member
On 18 Mar, 03:59, David Fanning <n...@dfanning.com> wrote:
> Lasse Clausen writes:
>> Well thanks, that works, however it did not bring the speed boost I
>> had hoped for. So I had another thought: Actually, all data is one
>> line, not in one line per station as I said earlier. But I know that
>> each data set is 1440 characters long, so here is the outline of my
>> code, after I opened all the files:
>
>> info = file_info(input_filename)
>> lines = info.size/1440L
>
>> for i=0L, lines-1L do begin
>> point_lun, fin, i*1440L
>> readf, fin, line, format='(A1440)'
>> ; extracting station name
>> hstat = strlowcase(strmid(line, 12, 3))
>> ; find correct file unit
>> tmp = where(stats eq hstat)
>> printf, tmp[0]+1, line
>> endfor
>
> Well lots of string processing and WHERE's going
> on here, which I think is what is slowing things
> down. How about something like this:
>
> theLines = Assoc(lun, BytArr(1440))
> maxYear = Max(stats)
> for I=0L, lines-1L do begin
> aLine = theLines[I]
> ; extracting station name
> hstat = String(aLine[12:15])
> ; find correct file unit
> printf, (maxYear-hstat)+1, String(aLine)
> endfor
>
> 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.")

Yeeeha! This solution (thanks Lajos/David)
openr, fin, filename, /get_lun
theLines = Assoc(fin, BytArr(1440))
for i=0L, lines-1L do begin
aLine = theLines[I]
hstat = String(aLine[12:14])
tmp = where(stats eq hstat)
printf, tmp[0]+1, string(aline)
endfor

goes like sh** off a shovel! I will use that. However, I still do not
know why


openr, fin, filename, /get_lun
for i=0L, lines-1L do begin
point_lun, fin, i*1440L
readf, fin, line, format='(A1440)'
endwhile

(note that all the string processing and where is taken out) takes
about 30 seconds. Well, I supsect the format code, there isn't much
else to supsect. Can anybody explain to me why the above solution is
so slow?

Cheers
Lasse
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: replicating arrays
Next Topic: Re: Question about selecting images from Draw Widgets

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

Current Time: Fri Oct 10 17:00:12 PDT 2025

Total time taken to generate the page: 0.80504 seconds