read ascii [message #63629] |
Mon, 17 November 2008 02:20 |
julia.walterspiel
Messages: 35 Registered: July 2008
|
Member |
|
|
hi
i've been fiddling about this problem the whole morning and it seems I
can't get it done properly:
I'm trying to read in a huge (!) ascii-file ('test.dat') where the
first column is a string (name of station), followed by 2 columns with
integer values (second row date in the format yymmddhourminute, third
row integer numbers between 0 and 10).
example 'test.dat':
SMA 200001010010 0
SMA 200001010020 0
SMA 200001010030 1
SMA 200001010040 0
SMA 200001010050 3
SMA 200001010100 4
SMA 200001010110 5
SMA 200001010120 0
SMA 200001010130 0
SMA 200001010140 0
no header.
I don't know how many rows I got, but I'm sure it's a LOT, since excel
crashes when trying to copy the file :)
I'm using David's Code like this:
OPENR, lun, '/filepath/test.dat', / GET_LUN
station = strarr (1000000)
time = fltarr (1000000)
sunshine_duration = fltarr(1000000)
s = '???' --> not sure what to insert here
t = 0.0
sd = 0.0
count = 0
WHILE (NOT EOF(lun)) DO BEGIN
READF, lun, s, t, sd
station(count) = s
time (count) = t
sunshine_duration(count) = sd
count = count+1
ENDWHILE
station = station(0:count-1)
time = time(0:count-1)
sunshine_duration = sunshine_duration(0:count-1)
FREE_LUN, lun
then I get the error
"READF: Input conversion error. Unit: 101"
I tried to google this error but couldnt find any useful
information...
I figure, I don't understand 100% what I'm doing here, that's why I
don't see where I make the mistake...
furthermore, I'm not sure how the file is delimited (tab or white
space) if this is crucial to anything..?
any help appreciated!
cheers,
juls
|
|
|