Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Text-processing-2/Zkl/text-processing-2.zkl
Normal file
19
Task/Text-processing-2/Zkl/text-processing-2.zkl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// the RegExp engine has a low limit on groups so
|
||||
// I can't use it to select all fields, only verify them
|
||||
re:=RegExp(0'|^(\d+-\d+-\d+)| + 0'|\s+\d+\.\d+\s+-*\d+| * 24 + ".+$");
|
||||
w:=[1..].zip(File("readings.txt")); //-->lazy (line #,line)
|
||||
reg datep,N, good=0, dd=0;
|
||||
foreach n,line in (w){
|
||||
N=n; // since n is local to this scope
|
||||
if (not re.search(line)){ println("Line %d: malformed".fmt(n)); continue; }
|
||||
date:=line[re.matchedNs[1].xplode()]; // I can group the date field
|
||||
if (datep==date){ dd+=1; println("Line %4d: dup date: %s".fmt(n,date)); }
|
||||
datep=date;
|
||||
if (line.replace("\t"," ").split(" ").filter()[1,*] // blow fields apart, drop date
|
||||
.pump(Void,Void.Read, // get (reading,status)
|
||||
fcn(_,s){ // stop on first problem status and return True
|
||||
if(s.strip().toInt()<1) T(Void.Stop,True) else False
|
||||
})) continue;
|
||||
good+=1;
|
||||
}
|
||||
println("%d records read, %d duplicate dates, %d valid".fmt(N,dd,good));
|
||||
Loading…
Add table
Add a link
Reference in a new issue