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

Home » Public Forums » archive » Re: read multiple files with varying 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: read multiple files with varying names [message #66644 is a reply to message #66601] Fri, 29 May 2009 05:51 Go to previous messageGo to previous message
sophie.hoss is currently offline  sophie.hoss
Messages: 5
Registered: May 2009
Junior Member
On 28 Mai, 17:25, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
> sophie.h...@gmail.com wrote:
>>            s=strarr(cols)
>>            n=0
>>            while (~ eof(file) and (n lt rows_data -1 )) do begin
>>                    ; Read a line of data
>>                    readf,lun,s
>>                    ; Store it in data
>>                     data[*,n]=s
>>                    n=n+1       (*****)
>>            end
>>            data=data[*,0:n-1]
>
>> I did the while-loop because I learned that IDL might not read every
>> line separately. Don't know if it's the most elegant version but at
>> least it is one.
>
>> for the sake of my sanity, any help is appreciated!
>> cheers,
>> sophie
>
> Sophie,
> when reading strings, the whole line is read. So when you read in S, you
> are reading nb_cols LINES..  s[0] = line0, s[1] = line1 etc. You would
> have to read the whole line then separate the columns.
>
> You can do it in one step
>
> data = strarr(nbLines)
> readf,lun,data
>
> Jean- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Jean, thanks for that, but I'm still stuck with the same problem no
matter how I do it. I cut the code short to

CD, 'filepath'
ci_files = FILE_SEARCH('ci*', COUNT=num_ci_files_found)

for i = 0,(num_ci_files_found-1) do begin

file = ci_files(i)
rows = File_Lines(file)
OpenR, lun, file, /Get_Lun
header = StrArr(34)
ReadF, lun, header
Point_Lun, -lun, currentLocation
data = strarr(12, rows-(n_elements(header))) ; i know there's 12
columns
readF, lun, data

; from here on I want to extract one column only and
save this column (radiation data from one station for one month) in a
file where I later add values from all other stations for this
specific month, then take the average from all stations over the whole
month)

--> READF: End of file encountered.

Do I need to include a format statement? I read some posts saying it
is sometimes (in easy cases) better to forget about any format
statements...

thanks for your input...
sophie, going crazy
[Message index]
 
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: Am I having a blackout?
Next Topic: How to extract latitude and longitude information from HDF file?

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

Current Time: Wed Oct 08 18:19:55 PDT 2025

Total time taken to generate the page: 0.00426 seconds