(phixonline)-->
-- demo\rosetta\TextProcessing2.exw
with javascript_semantics -- (include version/first of next three lines only)
include readings.e -- global constant lines, or:
--assert(write_lines("readings.txt",lines)!=-1) -- first run, then:
--constant lines = read_lines("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}
curr, last
for i=1 to length(lines) do
string li = lines[i]
sequence r = scanf(li,fmt)
if length(r)!=1 then
printf(1,"bad line [%d]:%s\n",{i,li})
else
curr = r[1][1..3]
if i>1 and curr=last then
printf(1,"duplicate line for %04d/%02d/%02d\n",last)
end if
last = curr
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)})
?"done"
{} = wait_key()