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

Home » Public Forums » archive » How to read data with format codes?
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: How to read data with format codes? [message #70163 is a reply to message #70073] Sun, 14 March 2010 19:39 Go to previous message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
On Mar 13, 8:38 pm, Adam Solomon <rampa...@gmail.com> wrote:
> Hi all, I've been pulling my hair out over using readf with a format
> code. So I have a data file with three columns of floats, all
> separated by a |. Here's an example:
>
>  | 355.9559189095| -79.4625574877| 0.279817     |
>  | 355.5057979042| -79.4067330132| 0.189663     |
>  | 359.5215546187| -79.7976864503| 0.161308     |
>  | 357.7890741750| -79.6427829568| 0.026100     |
>  | 354.7163524970| -79.3099884939| 0.026578     |
>  | 354.6329916471| -79.3061286761| 0.025486     |
>  | 0.0561720211 | -79.8234642170| 0.025670     |
>  | 357.3786228505| -79.5728335169| 0.000030     |
>  | 356.7569554568| -79.5138546776| 0.199416     |
>  | 355.0388858964| -79.3264538270| 0.190393     |
>  | 354.8099356150| -79.2912157538| 0.026006     |
>  | 352.5968356937| -79.0184276231| 0.207497     |
>  | 352.4362834602| -79.0094360366| 0.217226     |
>  | 0.1800716026 | -79.8081762850| 0.091767     |
>  | 359.0525340400| -79.7227001135| 0.205676     |
>  | 354.7045386126| -79.2652363648| 0.119250     |
>
> So every format code I've used which has even come close to working
> runs into issues at one point or another, probably because of the
> variable spacing. I want to read this file into three arrays, or a
> 3xlots array, or whatever - just any way to read in this data!! It's
> unbelievable that such a simple task is proving to be so difficult.
>
> I won't bore you with all the format codes I've tried (none of which
> have worked) but here's the most recent example:
>
> data=fltarr(3,rows-100);the 100 is so i don't run into EOF issues yet,
> just for testing
> readf,lun,data,format='(3(2x,F0.0))'
>
> The problems with this particular one are that when the first column
> is longer (as in most of these examples), the minus sign doesn't get
> read in the second column, and there may be issues reading the third
> column (not sure; will look into it some more).
>
> What's the appropriate way to read these data in?

I's just use readcol from Astrolib.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: SIGN function: signof(num or array of num)
Next Topic: Re: SIGN function: signof(num or array of num)

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

Current Time: Sat Oct 11 15:03:37 PDT 2025

Total time taken to generate the page: 2.72065 seconds