Re: Reading data, without column header [message #79948] |
Wed, 11 April 2012 06:29  |
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)
|
|
|