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

Home » Public Forums » archive » Re: Reading and Plotting big txt. File
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 and Plotting big txt. File [message #55109 is a reply to message #55104] Wed, 01 August 2007 05:58 Go to previous messageGo to previous message
Conor is currently offline  Conor
Messages: 138
Registered: February 2007
Senior Member
On Aug 1, 5:33 am, "incognito.me" <incognito...@gmx.de> wrote:
> I'm trying to read and plot (surface) a very big text (.txt) file
> (1020, 1024) with a 5 line string Header in IDL. My file looks like a
> circle made of numbers!!!. That means in some lines and colums there
> are no numbers only blanks!!!for example my file contains integers
> between rows 633 and 390 and between columns 650 and 406.At the left
> side of the file, there are the numbers of rows (1023,1022,1021,....0)
> my code should not read, but it does. And I also notice, that my code
> don't begin to read where the data starts!!By running the code I have
> the following error message: READF: End of file encountered. Unit: 1.
> Can someone help me?
> This is how my code looks like
> pro readfile, filename
>
> ; file=strupcase(filename)
> rows=file_lines(file)
> ;open the file and read the five line header.
> openr,1,file
> header=strarr(5)
> readf,1,header
> ; Find the number of columns in the file
> cols=fix(strmid(header(3),14,4))
> ; Number of rows of the data
> rows_data=rows-n_elements(header)
>
> ;Create a big array to hold the data
> data=intarr (cols, rows_data)
> ; All blanks should be replaced by zero
> data[where(data eq ' ')]=0
> ; A small array to read a line
> s=intarr(cols)
> n=0
> while (~ eof(1) and (n lt rows_data -1 )) do begin
> ; Read a line of data
> readf,1,s
> ; Store it in data
> data[*,n]=s
> n=n+1
> end
> data=data[*,0:n-1]
>
> CLOSE,1
> Shade_surf, data
> end
>
> thanks
>
> incognito

Really, I would second Peter's suggestion. You should find some way
to pre-process the file, specifically, so that there is the same
number of columns in each row. If you replace all the blank columns
with zero columns, then IDL will no longer have trouble reading your
file. I assume that is what you were trying to do with the line
'data[where(data eq ' ')]=0', except that you hadn't read any data
yet (and it wouldn't have worked anyway). For instance, if you had:

24 85 36 42
32 16

and you replaced all blanks with zeroes, you'd get:

24085036042
32000000016

which clearly isn't what you want. You want this:

24 85 36 42
32 00 00 16

which is unfortunately not so simple.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
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: Question on collection change - MOD07 air profile
Next Topic: Re: Another HDF File Question

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

Current Time: Wed Oct 08 18:52:40 PDT 2025

Total time taken to generate the page: 0.00477 seconds