34 lines
978 B
Plaintext
34 lines
978 B
Plaintext
sequence lines = read_lines("demo\\rosetta\\readings.txt")
|
|
|
|
include builtins\timedate.e
|
|
|
|
integer all_good = 0
|
|
|
|
string fmt = "%d-%d-%d\t"&join(repeat("%f",48),'\t')
|
|
sequence extset = sq_mul(tagset(24),2) -- {2,4,6,..48}
|
|
|
|
--The extract routine has been added as a builtin for 0.8.0+. If you don't yet have it, just use this:
|
|
--function extract(sequence source, indexes)
|
|
-- for i=1 to length(indexes) do
|
|
-- indexes[i] = source[indexes[i]]
|
|
-- end for
|
|
-- return indexes
|
|
--end function
|
|
|
|
for i=1 to length(lines) do
|
|
string li = lines[i]
|
|
sequence r = scanf(li,fmt), this, last
|
|
if length(r)!=1 then
|
|
printf(1,"bad line [%d]:%s\n",{i,li})
|
|
else
|
|
this = r[1][1..3]
|
|
if i>1 and this=last then
|
|
printf(1,"duplicate line for %04d/%02d/%02d\n",last)
|
|
end if
|
|
last = this
|
|
all_good += sum(sq_le(extract(r[1][4..$],extset),0))=0
|
|
end if
|
|
end for
|
|
|
|
printf(1,"Valid records %d of %d total\n",{all_good, length(lines)})
|