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

Home » Public Forums » archive » READF data containing numbers and strings
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: READF data containing numbers and strings [message #31061 is a reply to message #30997] Mon, 03 June 2002 23:22 Go to previous messageGo to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Eric Vella wrote:
>
> I need to read data from a file which contain lines with mixed variables
> including strings, for example "1 2 text 3". I tried "READF, int1, int2,
> str1, int3", but str1 gobbles up the rest of the line, leaving nothing for
> int3. This happens even if I supply an explicit format like A4 for the
> string. I can read the entire line into a single string, but then how do I
> separate the variables? STR_SEP does not work, since the separation
> character has to be a blank, and there can be multiple blanks between
> variables. I am hoping there is something simple I am missing (as is
> usually the case with IDL, simple only after you know the answer) ....

Dear Eric

here is a small program which should explain itselfs.



pro test

s={var1:bytarr(2),var2:bytarr(3),var3:bytarr(4),var5:bytarr( 2)}
x=fileline('data.txt',bytarr=byt)
; x is the number of lines
; could be used to replicate s
reads,byt,s
n=n_tags(s)
For i=0,n-1 do $
if is_number(string(s.(i))) then print, float(string(s.(i))) $
else print, string(s.(i))
end

1.00000
2.00000
text
3.00000


Used routines from our library are:

http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/fileline.tar.gz
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/is_number.tar.gz


regards
Reimar

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: the length of line
Next Topic: Structure reforming

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

Current Time: Sun Oct 19 08:42:58 PDT 2025

Total time taken to generate the page: 3.84212 seconds