Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
41
Task/Text-processing-1/11l/text-processing-1.11l
Normal file
41
Task/Text-processing-1/11l/text-processing-1.11l
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
V nodata = 0
|
||||
V nodata_max = -1
|
||||
[String] nodata_maxline
|
||||
V tot_file = 0.0
|
||||
V num_file = 0
|
||||
|
||||
:start:
|
||||
L(line) File(:argv[1]).read().rtrim("\n").split("\n")
|
||||
V tot_line = 0.0
|
||||
V num_line = 0
|
||||
|
||||
V field = line.split("\t")
|
||||
V date = field[0]
|
||||
V data = field[(1..).step(2)].map(f -> Float(f))
|
||||
V flags = field[(2..).step(2)].map(f -> Int(f))
|
||||
|
||||
L(datum, flag) zip(data, flags)
|
||||
I flag < 1
|
||||
nodata++
|
||||
E
|
||||
I nodata_max == nodata & nodata > 0
|
||||
nodata_maxline.append(date)
|
||||
I nodata_max < nodata & nodata > 0
|
||||
nodata_max = nodata
|
||||
nodata_maxline = [date]
|
||||
nodata = 0
|
||||
tot_line += datum
|
||||
num_line++
|
||||
|
||||
tot_file += tot_line
|
||||
num_file += num_line
|
||||
|
||||
print(‘Line: #11 Reject: #2 Accept: #2 Line_tot: #6.3 Line_avg: #6.3’.format(
|
||||
date, data.len - num_line, num_line, tot_line, I (num_line > 0) {tot_line / num_line} E 0))
|
||||
|
||||
print()
|
||||
print(‘File(s) = #.’.format(:argv[1]))
|
||||
print(‘Total = #6.3’.format(tot_file))
|
||||
print(‘Readings = #6’.format(num_file))
|
||||
print(‘Average = #6.3’.format(tot_file / num_file))
|
||||
print("\nMaximum run(s) of #. consecutive false readings ends at line starting with date(s): #.".format(nodata_max, nodata_maxline.join(‘, ’)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue