September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
33
Task/Text-processing-2/Phix/text-processing-2.phix
Normal file
33
Task/Text-processing-2/Phix/text-processing-2.phix
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
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)})
|
||||
Loading…
Add table
Add a link
Reference in a new issue