34 lines
1.1 KiB
Plaintext
34 lines
1.1 KiB
Plaintext
procedure main(A)
|
|
dups := set()
|
|
goodRecords := 0
|
|
lastDate := badFile := &null
|
|
f := A[1] | "readings.txt"
|
|
fin := open(f) | stop("Cannot open file '",f,"'")
|
|
|
|
while (fields := 0, badReading := &null, line := read(fin)) do {
|
|
line ? {
|
|
ldate := tab(many(&digits ++ '-')) | (badFile := "yes", next)
|
|
if \lastDate == ldate then insert(dups, ldate)
|
|
lastDate := ldate
|
|
while tab(many(' \t')) do {
|
|
(value := real(tab(many(&digits++'-.'))),
|
|
tab(many(' \t')),
|
|
flag := integer(tab(many(&digits++'-'))),
|
|
fields +:= 1) | (badFile := "yes")
|
|
if flag < 1 then badReading := "yes"
|
|
}
|
|
}
|
|
if fields = 24 then goodRecords +:= (/badReading, 1)
|
|
else badFile := "yes"
|
|
}
|
|
|
|
if (\badFile) then write(f," has field format issues.")
|
|
write("There are ",goodRecords," records with all good readings.")
|
|
if *dups > 0 then {
|
|
write("The following dates have multiple records:")
|
|
every writes(" ",!sort(dups))
|
|
write()
|
|
}
|
|
|
|
end
|