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

Home » Public Forums » archive » reading files with date- and time - columns
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: Reading files [message #64055 is a reply to message #23914] Sat, 29 November 2008 18:13 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Nov 29, 10:30 am, Wolfi <sfsdf.df...@yahoo.com> wrote:
> I'm trying to read a file, which is formed by words and numbers are
> follow
>
> name          0.2    4.1     6.0
> othename    1.6    3 .2    5.2
> ...
> etc  etc ...
>
> Usually I have been using the routine readcol, which works just fine,
> though it's limited at max 25 column (and it's not so fast for very
> large array od data).
>
> I was thinking to use
>
> matrix=fltarr(size)
> openr,1,'myfile'
> readf,1,matrix
> close,1
>
> but of course it get stuck because the first row is actually a string.
> Any idea how to do?

You could always use sed or awk or something to get rid of the first
column before reading it into idl... something like:

matrix = fltarr(ncols,nrows)
spawn, 'sed -e "s/^[^ ]* //" < filename', strippedfile
reads, strippedfile, matrix

(of course, that assumes that you're using an OS that has sed)


> Question number two. I want to read different files, named
> file1,file2,file3 etc ...
> Is there any way I can use a counter something like
>
> for i=1,3 do begin
> readcol,'file"$i"'
>
> thanks in advance!
> M.

string(i, format='(%"file%d")')

-Jeremy.
[Message index]
 
Read Message
Read Message
Previous Topic: Reading files
Next Topic: IDL Programming Techniques, 3rd edition

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

Current Time: Sat Nov 29 20:41:22 PST 2025

Total time taken to generate the page: 1.44000 seconds