Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Text-processing-2/Icon/text-processing-2.icon
Normal file
33
Task/Text-processing-2/Icon/text-processing-2.icon
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue