Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Text-processing-2/Picat/text-processing-2.picat
Normal file
25
Task/Text-processing-2/Picat/text-processing-2.picat
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import util.
|
||||
|
||||
go =>
|
||||
Readings = [split(Record) : Record in read_file_lines("readings.txt")],
|
||||
DateStamps = new_map(),
|
||||
GoodReadings = 0,
|
||||
foreach({Rec,Id} in zip(Readings,1..Readings.length))
|
||||
if Rec.length != 49 then printf("Entry %d has bad_length %d\n", Id, Rec.length) end,
|
||||
Date = Rec[1],
|
||||
if DateStamps.has_key(Date) then
|
||||
printf("Entry %d (date %w) is a duplicate of entry %w\n", Id, Date, DateStamps.get(Date))
|
||||
else
|
||||
if sum([1: I in 3..2..49, check_field(Rec[I])]) == 0 then
|
||||
GoodReadings := GoodReadings + 1
|
||||
end
|
||||
end,
|
||||
DateStamps.put(Date, Id)
|
||||
end,
|
||||
nl,
|
||||
printf("Total readings: %d\n",Readings.len),
|
||||
printf("Good readings: %d\n",GoodReadings),
|
||||
nl.
|
||||
|
||||
check_field(Field) =>
|
||||
Field == "-2" ; Field == "-1" ; Field == "0".
|
||||
Loading…
Add table
Add a link
Reference in a new issue