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

Home » Public Forums » archive » Error using data structures while reading ASCII file with different data types
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Error using data structures while reading ASCII file with different data types [message #87438] Mon, 03 February 2014 08:51 Go to previous message
atmospheric physics is currently offline  atmospheric physics
Messages: 121
Registered: June 2010
Senior Member
Hello,

I have the following data in an ASCII file (filename.txt):

2006-01-31 08:59:26 65.04 22.92 0.207226 0.150028 0.000000 0.057198
2006-01-31 08:59:26 65.22 22.92 0.231006 0.167339 0.000000 0.063667
2006-01-31 08:59:26 65.40 22.92 0.273280 0.201961 0.000000 0.071319
2006-01-31 08:59:26 65.58 22.92 0.255984 0.190420 0.000000 0.065564
2006-01-31 08:59:26 65.76 22.92 0.303038 0.225042 0.000000 0.077996
...
...
...


I tried to read this file with the following lines in IDL:
; ----------------------------------
PRO test.pro

nlines=FILE_LINES('filename.txt')
file_data=STRARR(nlines)
OPENR,lun,'filename.txt',/GET_LUN
READF,lun,file_data
CLOSE,lun & FREE_LUN,lun

dataStruct= { yyyy:0, mm:0, dd:0, hr:0, mi:0, sec:0, $
lon:0.0, lat:0.0, p1:0.0, p2:0.0, p3:0.0, p4:0.0 }

data=REPLICATE(dataStruct,nlines)
FOR ii=0,(nlines-1) DO BEGIN

str=file_data[ii]

str_array=STRSPLIT(str,' ',/EXTRACT)
yyyymmdd=STRSPLIT(str_array(0),'-',/EXTRACT)
hhmmss=STRSPLIT(str_array(1),':',/EXTRACT)

year=FIX(yyyymmdd(0)) & month=FIX(yyyymmdd(1)) & day=FIX(yyyymmdd(2))
hour=FIX(hhmmss(0)) & minutes=FIX(hhmmss(1)) & seconds=FIX(hhmmss(2))
long=FLOAT(str_array(2)) & lat=FLOAT(str_array(3))
par1=FLOAT(str_array(4)) & par2=FLOAT(str_array(5))
par3=FLOAT(str_array(6)) & par4=FLOAT(str_array(7))

data[*,ii]=[year,month,day,hour,minutes,seconds, $
long,lat,par1,par2,par3,par4]

ENDFOR

END
;-------------------------------------------------

I get the following error ...
% Conflicting data structures: POLDER_DATA,<FLOAT Array[12]>.

Can anyone suggest me where I am going wrong and what my mistake was? Any solution to my problem?

Thanks in advance ...
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: name a variable with number
Next Topic: Theil–Sen estimator anyone?

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

Current Time: Wed Oct 08 17:02:23 PDT 2025

Total time taken to generate the page: 0.00420 seconds