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

Home » Public Forums » archive » Re: Reading data, without column header
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 data, without column header [message #79948] Wed, 11 April 2012 06:29 Go to previous message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Wednesday, April 11, 2012 2:09:40 PM UTC+2, David Fanning wrote:
> shambhu writes:
>
>>
>> Hi
>>
>> I have a .dat file, which contains 5 columns. I want to read data of
>> the file in to other file for manipulation. I want to read it from
>> second row. Please tell me how to do.
>>
>>
>> I am using following code, but when i run first time it shows error
>> coz of type mis-match. When i continue with execution it works. Please
>> help mr to avoid his error.
>>
>> data = fltarr(5)
>> filename = '/scratch/shambhu/cdays.dat'
>> openr,lun,filename,/get_lun
>> rows=file_lines(file)
>>
>> for j=0, rows-1 do begin
>> readf, lun, data
>> t = data(0)
>> q = data(1)
>> Md = data(2)
>> h = data(3)
>> hplus = data(4)
>> endfor
>> free_lun, lun
>>
>>
>> Output:
>> IDL> readf, lun, data
>> % READF: Input conversion error. Unit: 100
>> File: /scratch/shambhu/cdays.dat
>> % Execution halted at: $MAIN$
>> IDL> readf, lun, data
>> IDL> print,data[0]
>> 289.021
>
> I would guess there is a header line, before the
> data starts. I would open the file in a text editor
> and see. If so, read the header before you read
> the data.
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

data=read_ascii(file)
[Message index]
 
Read Message
Read Message
Previous Topic: Reading data, without column header
Next Topic: Trouble with MPFITFUN

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

Current Time: Wed Oct 08 15:33:46 PDT 2025

Total time taken to generate the page: 0.00379 seconds