sycsvpro 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +29 -8
- data/bin/sycsvpro +68 -26
- data/html/Object.html +57 -0
- data/html/README_rdoc.html +18 -16
- data/html/Sycsvpro.html +2 -0
- data/html/Sycsvpro/Aggregator.html +482 -0
- data/html/Sycsvpro/Calculator.html +35 -8
- data/html/Sycsvpro/Counter.html +60 -27
- data/html/Sycsvpro/Filter.html +15 -12
- data/html/created.rid +9 -8
- data/html/index.html +20 -16
- data/html/js/search_index.js +1 -1
- data/html/table_of_contents.html +66 -38
- data/lib/sycsvpro.rb +1 -0
- data/lib/sycsvpro/aggregator.rb +112 -0
- data/lib/sycsvpro/calculator.rb +21 -5
- data/lib/sycsvpro/counter.rb +62 -16
- data/lib/sycsvpro/filter.rb +25 -9
- data/lib/sycsvpro/version.rb +1 -1
- data/spec/sycsvpro/aggregator_spec.rb +55 -0
- data/spec/sycsvpro/calculator_spec.rb +22 -0
- data/spec/sycsvpro/counter_spec.rb +77 -11
- data/sycsvpro.rdoc +17 -16
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b836321e6ea07a6f95c86d5a0f90b516851a15a
|
4
|
+
data.tar.gz: 79a6f3c56e4aeb83fc5f2a9fa25c7294e96a0086
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67be18777e87d10a65595f84feaebc1d06697b9350def8646e6638fa98da5915b24a9477ad61b4f7cd5dda1291fadaa8d0c3bc7c02a2b9d988a17c6ca7aee5dc
|
7
|
+
data.tar.gz: bf2ab9a8700ef5c019883f6dff2975a4042bad88cd8a928bcb74cf8516c06be07977f44137845b4787bc29a16ad88c4477ca3b047e13c3f7e6b60538ec591748
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -9,8 +9,9 @@ Processing of csv files. *sycsvpro* offers following functions
|
|
9
9
|
* map column values to new values
|
10
10
|
* allocate column values to a key column (since version 0.0.4)
|
11
11
|
* count values in columns and use the value as column name
|
12
|
+
* aggregate row values and add the sum to the end of the row
|
12
13
|
* arithmetic operations on values of columns
|
13
|
-
* sort rows
|
14
|
+
* sort rows based on columns (since version 0.0.9)
|
14
15
|
* insert rows to a csv-file (since version 0.0.8)
|
15
16
|
* create or edit a Ruby script
|
16
17
|
* list scripts available optionally with methods (since version 0.0.7)
|
@@ -110,7 +111,7 @@ Count
|
|
110
111
|
-----
|
111
112
|
Count all customers (key column) in rows 2 to 20 that have machines that start with *h* and have a contract valid beginning after 1.1.2000. Add a sum row with title Total at column 1
|
112
113
|
|
113
|
-
$ sycsvpro -f in.csv -o out.csv count -r 2-20 -k 0 -c 1:/^h/,5:">1.1.2000" --df "%d.%m.%Y" -s "Total:1"
|
114
|
+
$ sycsvpro -f in.csv -o out.csv count -r 2-20 -k 0:customer -c 1:/^h/,5:">1.1.2000" --df "%d.%m.%Y" -s "Total:1"
|
114
115
|
|
115
116
|
The result in file out.csv is
|
116
117
|
|
@@ -121,19 +122,39 @@ The result in file out.csv is
|
|
121
122
|
indix;1;0
|
122
123
|
chiro;2;0
|
123
124
|
|
125
|
+
It is possible to use multiple key columns `-k 0:customer,1:machines`
|
126
|
+
|
127
|
+
Aggregate
|
128
|
+
---------
|
129
|
+
Aggregate row values and add the sum to the end of the row. In the example we aggregate the customer names.
|
130
|
+
|
131
|
+
$ sycsvpro -f in.csv -o out.csv aggregate -c 0 -s Total:1,Sum
|
132
|
+
|
133
|
+
The aggregation result in out.csv is
|
134
|
+
|
135
|
+
$ cat out.csv
|
136
|
+
customer;Sum
|
137
|
+
Total;5
|
138
|
+
hello;2
|
139
|
+
indix;1
|
140
|
+
chiro;2
|
141
|
+
|
124
142
|
Calc
|
125
143
|
----
|
126
|
-
Process arithmetic operations on the contract count and create a target column
|
144
|
+
Process arithmetic operations on the contract count and create a target column and a sum which is added at the end of the result file
|
127
145
|
|
128
146
|
$ sycsvpro -f in.csv -o out.csv calc -r 2-20 -h *,target -c 6:*2,7:target=c6*10
|
129
147
|
|
130
148
|
$ cat out.csv
|
131
149
|
customer;machine;control;drive;motor;date;contract;target
|
132
|
-
hello;h1;con123;dri120;mot100;1.01.3013;
|
133
|
-
hello;h2;con123;dri130;mot110;1.02.3012;
|
134
|
-
indix;i1;con456;dri130;mot090;5.11.3013;
|
135
|
-
chiro;c1;con333;dri110;mot100;1.10.3011;
|
136
|
-
chiro;c2;con331;dri100;mot130;3.05.3010;
|
150
|
+
hello;h1;con123;dri120;mot100;1.01.3013;2;20
|
151
|
+
hello;h2;con123;dri130;mot110;1.02.3012;2;20
|
152
|
+
indix;i1;con456;dri130;mot090;5.11.3013;2;20
|
153
|
+
chiro;c1;con333;dri110;mot100;1.10.3011;2;20
|
154
|
+
chiro;c2;con331;dri100;mot130;3.05.3010;2;20
|
155
|
+
0;0;0;0;0;0;10;100
|
156
|
+
|
157
|
+
In the sum row non-numbers in the colums are converted to 0. Therefore column 0 is summed up to 0 as all strings are converted to 0.
|
137
158
|
|
138
159
|
Sort
|
139
160
|
----
|
data/bin/sycsvpro
CHANGED
@@ -58,8 +58,8 @@ end
|
|
58
58
|
desc 'Extract specified rows and columns from the file'
|
59
59
|
command :extract do |c|
|
60
60
|
c.desc 'Rows to extract'
|
61
|
-
c.arg_name '1,2,10-30
|
62
|
-
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d
|
61
|
+
c.arg_name '1,2,10-30,45-EOF,REGEXP'
|
62
|
+
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d+|-eof|,\/.*\/)*|\/.*\/(?:,\/.*\/|\d+)*/i
|
63
63
|
|
64
64
|
c.desc 'Columns to extract'
|
65
65
|
c.arg_name '1,2,10-30'
|
@@ -78,11 +78,11 @@ desc 'Collect values of specified rows and columns from the file and group them
|
|
78
78
|
command :collect do |c|
|
79
79
|
|
80
80
|
c.desc 'Rows to consider for collection'
|
81
|
-
c.arg_name 'ROW1,ROW2,ROW10-ROW30
|
82
|
-
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d
|
81
|
+
c.arg_name 'ROW1,ROW2,ROW10-ROW30,45-EOF,REGEXP'
|
82
|
+
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d+|-eof|,\/.*\/)*|\/.*\/(?:,\/.*\/|\d+)*/i
|
83
83
|
|
84
84
|
c.desc 'Columns to collect values from'
|
85
|
-
c.arg_name 'CATEGORY1:
|
85
|
+
c.arg_name 'CATEGORY1:COL1,COL2,COL10-COL30+CATEGORY2:COL3-COL9'
|
86
86
|
c.flag [:c, :col], :must_match => /^\w*:\d+(?:,\d+|-\d+|\+\w*:\d+(?:,\d+|-\d+)*)*/
|
87
87
|
|
88
88
|
c.action do |global_options,options,args|
|
@@ -97,8 +97,8 @@ end
|
|
97
97
|
desc 'Allocate specified columns from the file to a key value'
|
98
98
|
command :allocate do |c|
|
99
99
|
c.desc 'Rows to consider'
|
100
|
-
c.arg_name '1,2,10-30
|
101
|
-
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d
|
100
|
+
c.arg_name '1,2,10-30,45-EOF,REGEXP'
|
101
|
+
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d+|-eof|,\/.*\/)*|\/.*\/(?:,\/.*\/|\d+)*/i
|
102
102
|
|
103
103
|
c.desc 'Key to allocate columns to'
|
104
104
|
c.arg_name '0'
|
@@ -192,21 +192,21 @@ desc 'Counts the occurences of column values. Uses column values as headings wit
|
|
192
192
|
|
193
193
|
command :count do |c|
|
194
194
|
|
195
|
-
c.desc 'Key
|
196
|
-
c.arg_name '
|
197
|
-
c.flag [:k, :key], :must_match => /^\d
|
195
|
+
c.desc 'Key columns that are assigned the count of column values'
|
196
|
+
c.arg_name 'COLUMN:TITLE,COLUMN:TITLE'
|
197
|
+
c.flag [:k, :key], :must_match => /^\d+:\w+(?:,\d+:\w+)*/
|
198
198
|
|
199
199
|
c.desc 'Rows to consider'
|
200
|
-
c.arg_name '1,2,10-30
|
201
|
-
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d
|
200
|
+
c.arg_name '1,2,10-30,45-EOF,REGEXP'
|
201
|
+
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d+|-eof|,\/.*\/)*|\/.*\/(?:,\/.*\/|\d+)*/i
|
202
202
|
|
203
|
-
c.desc 'Columns to count where
|
204
|
-
c.arg_name '1,2:<14.2.2014,10-30'
|
205
|
-
c.flag [:c, :col], :must_match => /^\d+(?:,\d+|(?::[<=>]\d+.\d+.\d+|:\d+.\d+.\d+-\d+.\d+.\d
|
203
|
+
c.desc 'Columns to count where columns 2 and 3 are counted conditionally'
|
204
|
+
c.arg_name '1,2:<14.2.2014,10-30,3:>10'
|
205
|
+
c.flag [:c, :col], :must_match => /^\d+(?:,\d+|(?::[<=>]\d+.\d+.\d+|:\d+.\d+.\d+-\d+.\d+.\d+|:\/.*?\/|:[<=>]\d+|:\d+-\d+|-\d+)*)*/
|
206
206
|
|
207
207
|
c.desc 'Adds a sum row with TITLE for the counted columns at the specified row position'
|
208
|
-
c.arg_name '
|
209
|
-
c.flag [:s, :sum], :must_match => /^\w+:\d+/
|
208
|
+
c.arg_name 'SUM_ROW_TITLE:ROW,SUM_COL_TITLE'
|
209
|
+
c.flag [:s, :sum], :must_match => /^\w+:\d+(?:,\w+)?|^\w+/
|
210
210
|
|
211
211
|
c.desc 'Format of date values'
|
212
212
|
c.arg_name '%d.%m.%Y|%m/%d/%Y|...'
|
@@ -223,11 +223,38 @@ command :count do |c|
|
|
223
223
|
|
224
224
|
end
|
225
225
|
|
226
|
+
desc 'Aggregates the occurences of row values. Optionally adds a sum row'
|
227
|
+
|
228
|
+
command :aggregate do |c|
|
229
|
+
|
230
|
+
c.desc 'Rows to consider'
|
231
|
+
c.arg_name '1,2,10-30,45-EOF,REGEXP'
|
232
|
+
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d+|-eof|,\/.*\/)*|\/.*\/(?:,\/.*\/|\d+)*/i
|
233
|
+
|
234
|
+
c.desc 'Columns to count'
|
235
|
+
c.arg_name '1,2-4'
|
236
|
+
c.flag [:c, :col], :must_match => /^\d+(?:,\d+|-\d+)*/
|
237
|
+
|
238
|
+
c.desc 'Adds a sum row and a sum column with TITLE for the counted columns. The sum row is ' +
|
239
|
+
'specified by the row position. The sum column is the last column in the row'
|
240
|
+
c.arg_name 'SUM_ROW_TITLE:ROW,SUM_COL_TITLE'
|
241
|
+
c.flag [:s, :sum], :must_match => /^\w+:\d+(?:,\w+)?|^\w+/
|
242
|
+
|
243
|
+
c.action do |global_options,options,args|
|
244
|
+
print "Aggregating..."
|
245
|
+
aggregator = Sycsvpro::Aggregator.new(infile: global_options[:f], outfile: global_options[:o],
|
246
|
+
rows: options[:r], cols: options[:c], sum: options[:s])
|
247
|
+
aggregator.execute
|
248
|
+
puts "done"
|
249
|
+
end
|
250
|
+
|
251
|
+
end
|
252
|
+
|
226
253
|
desc 'Sort rows based on column values'
|
227
254
|
command :sort do |c|
|
228
255
|
c.desc 'Rows to consider'
|
229
|
-
c.arg_name '1,2,10-30
|
230
|
-
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d
|
256
|
+
c.arg_name '1,2,10-30,45-EOF,REGEXP'
|
257
|
+
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d+|-eof|,\/.*\/)*|\/.*\/(?:,\/.*\/|\d+)*/i
|
231
258
|
|
232
259
|
c.desc 'Columns to sort based on a type (n = number, s = string, d = date) and its value'
|
233
260
|
c.arg_name 'n:1,s:2-5,d:7'
|
@@ -282,8 +309,8 @@ desc 'Map values in columns to new values'
|
|
282
309
|
arg_name 'MAPPINGS-FILE'
|
283
310
|
command :map do |c|
|
284
311
|
c.desc 'Rows to consider'
|
285
|
-
c.arg_name 'ROW1,ROW2,ROW10-ROW30
|
286
|
-
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d
|
312
|
+
c.arg_name 'ROW1,ROW2,ROW10-ROW30,45-EOF,REGEXP'
|
313
|
+
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d+|-eof|,\/.*\/)*|\/.*\/(?:,\/.*\/|\d+)*/i
|
287
314
|
|
288
315
|
c.desc 'Columns to consider for mapping'
|
289
316
|
c.arg_name 'COL1,COL2,COL10-COL30'
|
@@ -300,7 +327,7 @@ command :map do |c|
|
|
300
327
|
end
|
301
328
|
end
|
302
329
|
|
303
|
-
desc 'Process math operations on columns'
|
330
|
+
desc 'Process math operations on columns. Optionally add a sum row'
|
304
331
|
command :calc do |c|
|
305
332
|
c.desc 'The first non-empty column is considered the header. '+
|
306
333
|
'If additional columns are created then *,COL1,COL2 will create the additional header '+
|
@@ -310,19 +337,23 @@ command :calc do |c|
|
|
310
337
|
c.flag [:h, :header], :must_match => /\*(?:,\w+)*/
|
311
338
|
|
312
339
|
c.desc 'Columns to consider for calculations'
|
313
|
-
c.arg_name 'ROW1,ROW2-ROW10
|
314
|
-
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d
|
340
|
+
c.arg_name 'ROW1,ROW2-ROW10,45-EOF,REGEXP'
|
341
|
+
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d+|-eof|,\/.*\/)*|\/.*\/(?:,\/.*\/|\d+)*/i
|
315
342
|
|
316
343
|
c.desc 'Column to do calculations on'
|
317
344
|
c.arg_name 'COL1:*2,COL2:-C3,COL3:*2+(4+C5),COL6:NEW_COL=C1+5'
|
318
345
|
c.flag [:c, :col], :must_match => /\d+:(?:[\*\/\+\-]|\w+=[\d|(]*)[\*\/\+\-\dc()]*(?:,\d+:(?:[\*\/\+\-]|\w+=[\d|(]*)[\*\/\+\-\dc()]*)*/
|
319
346
|
|
347
|
+
c.desc 'Indicate to add a sum row'
|
348
|
+
c.switch [:s, :sum]
|
349
|
+
|
320
350
|
c.action do |global_options,options,args|
|
321
351
|
help_now! "You need to provide the column flag" if options[:c].nil?
|
322
352
|
|
323
353
|
print "Calculating..."
|
324
354
|
calculator = Sycsvpro::Calculator.new(infile: global_options[:f], outfile: global_options[:o],
|
325
|
-
header: options[:h], rows: options[:r], cols: options[:c]
|
355
|
+
header: options[:h], rows: options[:r], cols: options[:c],
|
356
|
+
sum: options[:s])
|
326
357
|
calculator.execute
|
327
358
|
puts "done"
|
328
359
|
end
|
@@ -338,7 +369,7 @@ pre do |global,command,options,args|
|
|
338
369
|
case command.name
|
339
370
|
when :analyze
|
340
371
|
help_now! "You need to provide an input file '-f FILE'" if global[:f].nil?
|
341
|
-
when :allocate, :calc, :collect, :count, :extract, :map, :sort
|
372
|
+
when :aggregate, :allocate, :calc, :collect, :count, :extract, :map, :sort
|
342
373
|
help_now! "You need to provide an input file '-f FILE'" if global[:f].nil?
|
343
374
|
help_now! "You need to provide a result file '-o OUT_FILE'" if global[:o].nil?
|
344
375
|
end
|
@@ -349,6 +380,7 @@ pre do |global,command,options,args|
|
|
349
380
|
analyzer = Sycsvpro::Analyzer.new(global[:f])
|
350
381
|
result = analyzer.result
|
351
382
|
count = result.row_count
|
383
|
+
set_max_row(options, count)
|
352
384
|
end
|
353
385
|
|
354
386
|
# Creates statistics on the command operation
|
@@ -418,4 +450,14 @@ on_error do |exception|
|
|
418
450
|
true
|
419
451
|
end
|
420
452
|
|
453
|
+
# the -r flag can take a EOF value which is replaced by the actual row value of the input file
|
454
|
+
def set_max_row(options, max_row)
|
455
|
+
options.each do |option, value|
|
456
|
+
case option
|
457
|
+
when "r", :r, "row", :row
|
458
|
+
options[option] = options[option].sub(/EOF/i, max_row.to_s) if options[option] =~ /EOF/i
|
459
|
+
end
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
421
463
|
exit run(ARGV)
|
data/html/Object.html
CHANGED
@@ -78,7 +78,17 @@
|
|
78
78
|
</div>
|
79
79
|
|
80
80
|
|
81
|
+
<!-- Method Quickref -->
|
82
|
+
<div id="method-list-section" class="nav-section">
|
83
|
+
<h3>Methods</h3>
|
84
|
+
|
85
|
+
<ul class="link-list" role="directory">
|
86
|
+
|
87
|
+
<li ><a href="#method-i-set_max_row">#set_max_row</a>
|
81
88
|
|
89
|
+
</ul>
|
90
|
+
</div>
|
91
|
+
|
82
92
|
</div>
|
83
93
|
</nav>
|
84
94
|
|
@@ -118,6 +128,53 @@
|
|
118
128
|
|
119
129
|
|
120
130
|
|
131
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
132
|
+
<header>
|
133
|
+
<h3>Public Instance Methods</h3>
|
134
|
+
</header>
|
135
|
+
|
136
|
+
|
137
|
+
<div id="method-i-set_max_row" class="method-detail ">
|
138
|
+
|
139
|
+
<div class="method-heading">
|
140
|
+
<span class="method-name">set_max_row</span><span
|
141
|
+
class="method-args">(options, max_row)</span>
|
142
|
+
|
143
|
+
<span class="method-click-advice">click to toggle source</span>
|
144
|
+
|
145
|
+
</div>
|
146
|
+
|
147
|
+
|
148
|
+
<div class="method-description">
|
149
|
+
|
150
|
+
<p>the -r flag can take a EOF value which is replaced by the actual row value
|
151
|
+
of the input file</p>
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
<div class="method-source-code" id="set_max_row-source">
|
157
|
+
<pre><span class="ruby-comment"># File bin/sycsvpro, line 454</span>
|
158
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">set_max_row</span>(<span class="ruby-identifier">options</span>, <span class="ruby-identifier">max_row</span>)
|
159
|
+
<span class="ruby-identifier">options</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">option</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
160
|
+
<span class="ruby-keyword">case</span> <span class="ruby-identifier">option</span>
|
161
|
+
<span class="ruby-keyword">when</span> <span class="ruby-string">"r"</span>, <span class="ruby-value">:r</span>, <span class="ruby-string">"row"</span>, <span class="ruby-value">:row</span>
|
162
|
+
<span class="ruby-identifier">options</span>[<span class="ruby-identifier">option</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">option</span>].<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/EOF/i</span>, <span class="ruby-identifier">max_row</span>.<span class="ruby-identifier">to_s</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">option</span>] <span class="ruby-operator">=~</span> <span class="ruby-regexp">/EOF/i</span>
|
163
|
+
<span class="ruby-keyword">end</span>
|
164
|
+
<span class="ruby-keyword">end</span>
|
165
|
+
<span class="ruby-keyword">end</span></pre>
|
166
|
+
</div>
|
167
|
+
|
168
|
+
</div>
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
</div>
|
174
|
+
|
175
|
+
|
176
|
+
</section>
|
177
|
+
|
121
178
|
</section>
|
122
179
|
</main>
|
123
180
|
|
data/html/README_rdoc.html
CHANGED
@@ -147,32 +147,34 @@ bin</pre>
|
|
147
147
|
|
148
148
|
<p>VERSION</p>
|
149
149
|
|
150
|
-
<pre>0.0
|
150
|
+
<pre>0.1.0</pre>
|
151
151
|
|
152
152
|
<p>GLOBAL OPTIONS</p>
|
153
153
|
|
154
154
|
<pre>-f, --file=FILE - CSV file to operate on (default: none)
|
155
155
|
--help - Show this message
|
156
156
|
-o, --out=OUT_FILE - CSV file to write the result to (default: none)
|
157
|
+
-s, --[no-]silent - Silent progress doesn't show progress indicator
|
157
158
|
--version - Display the program version</pre>
|
158
159
|
|
159
160
|
<p>COMMANDS</p>
|
160
161
|
|
161
|
-
<pre>
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
162
|
+
<pre>aggregate - Aggregates the occurences of row values. Optionally adds a sum row
|
163
|
+
allocate - Allocate specified columns from the file to a key value
|
164
|
+
analyze - Analyze the CSV file regarding columns, rows and content
|
165
|
+
calc - Process math operations on columns. Optionally adds a sum row
|
166
|
+
collect - Collect values of specified rows and columns from the file and group them in
|
167
|
+
categories
|
168
|
+
count - Counts the occurences of column values. Uses column values as headings with count as
|
169
|
+
values. Columns with a condition will be added as new columns and the condition will
|
170
|
+
be set as column name. Optionally adds a sum row
|
171
|
+
execute - Executes the code provided in a file
|
172
|
+
extract - Extract specified rows and columns from the file
|
173
|
+
help - Shows a list of commands or help for one command
|
174
|
+
insert - Inserts rows from a file to a csv-file
|
175
|
+
list - List scripts in the scripts directory with optionally listing methods
|
176
|
+
map - Map values in columns to new values
|
177
|
+
sort - Sort columns based on column values</pre>
|
176
178
|
</main>
|
177
179
|
|
178
180
|
|
data/html/Sycsvpro.html
CHANGED
@@ -0,0 +1,482 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class Sycsvpro::Aggregator - Your application title</title>
|
8
|
+
|
9
|
+
<link href="../fonts.css" rel="stylesheet">
|
10
|
+
<link href="../rdoc.css" rel="stylesheet">
|
11
|
+
|
12
|
+
<script type="text/javascript">
|
13
|
+
var rdoc_rel_prefix = "../";
|
14
|
+
</script>
|
15
|
+
|
16
|
+
<script src="../js/jquery.js"></script>
|
17
|
+
<script src="../js/navigation.js"></script>
|
18
|
+
<script src="../js/search_index.js"></script>
|
19
|
+
<script src="../js/search.js"></script>
|
20
|
+
<script src="../js/searcher.js"></script>
|
21
|
+
<script src="../js/darkfish.js"></script>
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="class">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="class-metadata">
|
59
|
+
|
60
|
+
<div id="parent-class-section" class="nav-section">
|
61
|
+
<h3>Parent</h3>
|
62
|
+
|
63
|
+
|
64
|
+
<p class="link"><a href="../Object.html">Object</a>
|
65
|
+
|
66
|
+
</div>
|
67
|
+
|
68
|
+
<div id="includes-section" class="nav-section">
|
69
|
+
<h3>Included Modules</h3>
|
70
|
+
|
71
|
+
<ul class="link-list">
|
72
|
+
|
73
|
+
|
74
|
+
<li><a class="include" href="../Dsl.html">Dsl</a>
|
75
|
+
|
76
|
+
|
77
|
+
</ul>
|
78
|
+
</div>
|
79
|
+
|
80
|
+
|
81
|
+
<!-- Method Quickref -->
|
82
|
+
<div id="method-list-section" class="nav-section">
|
83
|
+
<h3>Methods</h3>
|
84
|
+
|
85
|
+
<ul class="link-list" role="directory">
|
86
|
+
|
87
|
+
<li ><a href="#method-c-new">::new</a>
|
88
|
+
|
89
|
+
<li ><a href="#method-i-execute">#execute</a>
|
90
|
+
|
91
|
+
<li ><a href="#method-i-process_aggregation">#process_aggregation</a>
|
92
|
+
|
93
|
+
<li ><a href="#method-i-write_result">#write_result</a>
|
94
|
+
|
95
|
+
</ul>
|
96
|
+
</div>
|
97
|
+
|
98
|
+
</div>
|
99
|
+
</nav>
|
100
|
+
|
101
|
+
<main role="main" aria-labelledby="class-Sycsvpro::Aggregator">
|
102
|
+
<h1 id="class-Sycsvpro::Aggregator" class="class">
|
103
|
+
class Sycsvpro::Aggregator
|
104
|
+
</h1>
|
105
|
+
|
106
|
+
<section class="description">
|
107
|
+
|
108
|
+
<p>An <a href="Aggregator.html">Aggregator</a> counts specified row values and
|
109
|
+
adds a sum to the end of the row</p>
|
110
|
+
|
111
|
+
</section>
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
<section class="attribute-method-details" class="method-section">
|
125
|
+
<header>
|
126
|
+
<h3>Attributes</h3>
|
127
|
+
</header>
|
128
|
+
|
129
|
+
|
130
|
+
<div id="attribute-i-col_filter" class="method-detail">
|
131
|
+
<div class="method-heading attribute-method-heading">
|
132
|
+
<span class="method-name">col_filter</span><span
|
133
|
+
class="attribute-access-type">[R]</span>
|
134
|
+
</div>
|
135
|
+
|
136
|
+
<div class="method-description">
|
137
|
+
|
138
|
+
<p>filter that is used for columns</p>
|
139
|
+
|
140
|
+
</div>
|
141
|
+
</div>
|
142
|
+
|
143
|
+
<div id="attribute-i-headerless" class="method-detail">
|
144
|
+
<div class="method-heading attribute-method-heading">
|
145
|
+
<span class="method-name">headerless</span><span
|
146
|
+
class="attribute-access-type">[R]</span>
|
147
|
+
</div>
|
148
|
+
|
149
|
+
<div class="method-description">
|
150
|
+
|
151
|
+
<p>file doesn't contain a header</p>
|
152
|
+
|
153
|
+
</div>
|
154
|
+
</div>
|
155
|
+
|
156
|
+
<div id="attribute-i-heading" class="method-detail">
|
157
|
+
<div class="method-heading attribute-method-heading">
|
158
|
+
<span class="method-name">heading</span><span
|
159
|
+
class="attribute-access-type">[R]</span>
|
160
|
+
</div>
|
161
|
+
|
162
|
+
<div class="method-description">
|
163
|
+
|
164
|
+
<p>header of the out file</p>
|
165
|
+
|
166
|
+
</div>
|
167
|
+
</div>
|
168
|
+
|
169
|
+
<div id="attribute-i-infile" class="method-detail">
|
170
|
+
<div class="method-heading attribute-method-heading">
|
171
|
+
<span class="method-name">infile</span><span
|
172
|
+
class="attribute-access-type">[R]</span>
|
173
|
+
</div>
|
174
|
+
|
175
|
+
<div class="method-description">
|
176
|
+
|
177
|
+
<p>infile contains the data that is operated on</p>
|
178
|
+
|
179
|
+
</div>
|
180
|
+
</div>
|
181
|
+
|
182
|
+
<div id="attribute-i-key_values" class="method-detail">
|
183
|
+
<div class="method-heading attribute-method-heading">
|
184
|
+
<span class="method-name">key_values</span><span
|
185
|
+
class="attribute-access-type">[R]</span>
|
186
|
+
</div>
|
187
|
+
|
188
|
+
<div class="method-description">
|
189
|
+
|
190
|
+
<p>values that are aggregated</p>
|
191
|
+
|
192
|
+
</div>
|
193
|
+
</div>
|
194
|
+
|
195
|
+
<div id="attribute-i-outfile" class="method-detail">
|
196
|
+
<div class="method-heading attribute-method-heading">
|
197
|
+
<span class="method-name">outfile</span><span
|
198
|
+
class="attribute-access-type">[R]</span>
|
199
|
+
</div>
|
200
|
+
|
201
|
+
<div class="method-description">
|
202
|
+
|
203
|
+
<p>outfile is the file where the result is written to</p>
|
204
|
+
|
205
|
+
</div>
|
206
|
+
</div>
|
207
|
+
|
208
|
+
<div id="attribute-i-row_filter" class="method-detail">
|
209
|
+
<div class="method-heading attribute-method-heading">
|
210
|
+
<span class="method-name">row_filter</span><span
|
211
|
+
class="attribute-access-type">[R]</span>
|
212
|
+
</div>
|
213
|
+
|
214
|
+
<div class="method-description">
|
215
|
+
|
216
|
+
<p>filter that is used for rows</p>
|
217
|
+
|
218
|
+
</div>
|
219
|
+
</div>
|
220
|
+
|
221
|
+
<div id="attribute-i-sum_col" class="method-detail">
|
222
|
+
<div class="method-heading attribute-method-heading">
|
223
|
+
<span class="method-name">sum_col</span><span
|
224
|
+
class="attribute-access-type">[R]</span>
|
225
|
+
</div>
|
226
|
+
|
227
|
+
<div class="method-description">
|
228
|
+
|
229
|
+
<p>column where to add the sum of the row sum</p>
|
230
|
+
|
231
|
+
</div>
|
232
|
+
</div>
|
233
|
+
|
234
|
+
<div id="attribute-i-sum_col_title" class="method-detail">
|
235
|
+
<div class="method-heading attribute-method-heading">
|
236
|
+
<span class="method-name">sum_col_title</span><span
|
237
|
+
class="attribute-access-type">[R]</span>
|
238
|
+
</div>
|
239
|
+
|
240
|
+
<div class="method-description">
|
241
|
+
|
242
|
+
<p>Title of the sum column</p>
|
243
|
+
|
244
|
+
</div>
|
245
|
+
</div>
|
246
|
+
|
247
|
+
<div id="attribute-i-sum_row" class="method-detail">
|
248
|
+
<div class="method-heading attribute-method-heading">
|
249
|
+
<span class="method-name">sum_row</span><span
|
250
|
+
class="attribute-access-type">[R]</span>
|
251
|
+
</div>
|
252
|
+
|
253
|
+
<div class="method-description">
|
254
|
+
|
255
|
+
<p>row where to add the sums of the columns</p>
|
256
|
+
|
257
|
+
</div>
|
258
|
+
</div>
|
259
|
+
|
260
|
+
<div id="attribute-i-sum_row_title" class="method-detail">
|
261
|
+
<div class="method-heading attribute-method-heading">
|
262
|
+
<span class="method-name">sum_row_title</span><span
|
263
|
+
class="attribute-access-type">[R]</span>
|
264
|
+
</div>
|
265
|
+
|
266
|
+
<div class="method-description">
|
267
|
+
|
268
|
+
<p>Title of the sum row</p>
|
269
|
+
|
270
|
+
</div>
|
271
|
+
</div>
|
272
|
+
|
273
|
+
<div id="attribute-i-sums" class="method-detail">
|
274
|
+
<div class="method-heading attribute-method-heading">
|
275
|
+
<span class="method-name">sums</span><span
|
276
|
+
class="attribute-access-type">[R]</span>
|
277
|
+
</div>
|
278
|
+
|
279
|
+
<div class="method-description">
|
280
|
+
|
281
|
+
<p>sums of the column values</p>
|
282
|
+
|
283
|
+
</div>
|
284
|
+
</div>
|
285
|
+
|
286
|
+
</section>
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
291
|
+
<header>
|
292
|
+
<h3>Public Class Methods</h3>
|
293
|
+
</header>
|
294
|
+
|
295
|
+
|
296
|
+
<div id="method-c-new" class="method-detail ">
|
297
|
+
|
298
|
+
<div class="method-heading">
|
299
|
+
<span class="method-name">new</span><span
|
300
|
+
class="method-args">(options={})</span>
|
301
|
+
|
302
|
+
<span class="method-click-advice">click to toggle source</span>
|
303
|
+
|
304
|
+
</div>
|
305
|
+
|
306
|
+
|
307
|
+
<div class="method-description">
|
308
|
+
|
309
|
+
<p>Creates a new aggregator. Takes as attributes infile, outfile, key, rows,
|
310
|
+
cols, date-format and indicator whether to add a sum row</p>
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
<div class="method-source-code" id="new-source">
|
316
|
+
<pre><span class="ruby-comment"># File lib/sycsvpro/aggregator.rb, line 40</span>
|
317
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>={})
|
318
|
+
<span class="ruby-ivar">@infile</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:infile</span>]
|
319
|
+
<span class="ruby-ivar">@outfile</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:outfile</span>]
|
320
|
+
<span class="ruby-ivar">@headerless</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:headerless</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword">false</span>
|
321
|
+
<span class="ruby-ivar">@row_filter</span> = <span class="ruby-constant">RowFilter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:rows</span>])
|
322
|
+
<span class="ruby-ivar">@col_filter</span> = <span class="ruby-constant">ColumnFilter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:cols</span>], <span class="ruby-identifier">df</span><span class="ruby-operator">:</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:df</span>])
|
323
|
+
<span class="ruby-ivar">@key_values</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">0</span>)
|
324
|
+
<span class="ruby-ivar">@heading</span> = []
|
325
|
+
<span class="ruby-ivar">@sums</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">0</span>)
|
326
|
+
<span class="ruby-identifier">init_sum_scheme</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:sum</span>])
|
327
|
+
<span class="ruby-keyword">end</span></pre>
|
328
|
+
</div>
|
329
|
+
|
330
|
+
</div>
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
</div>
|
336
|
+
|
337
|
+
|
338
|
+
</section>
|
339
|
+
|
340
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
341
|
+
<header>
|
342
|
+
<h3>Public Instance Methods</h3>
|
343
|
+
</header>
|
344
|
+
|
345
|
+
|
346
|
+
<div id="method-i-execute" class="method-detail ">
|
347
|
+
|
348
|
+
<div class="method-heading">
|
349
|
+
<span class="method-name">execute</span><span
|
350
|
+
class="method-args">()</span>
|
351
|
+
|
352
|
+
<span class="method-click-advice">click to toggle source</span>
|
353
|
+
|
354
|
+
</div>
|
355
|
+
|
356
|
+
|
357
|
+
<div class="method-description">
|
358
|
+
|
359
|
+
<p>Executes the aggregator</p>
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
<div class="method-source-code" id="execute-source">
|
365
|
+
<pre><span class="ruby-comment"># File lib/sycsvpro/aggregator.rb, line 53</span>
|
366
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">execute</span>
|
367
|
+
<span class="ruby-identifier">process_aggregation</span>
|
368
|
+
<span class="ruby-identifier">write_result</span>
|
369
|
+
<span class="ruby-keyword">end</span></pre>
|
370
|
+
</div>
|
371
|
+
|
372
|
+
</div>
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
</div>
|
378
|
+
|
379
|
+
|
380
|
+
<div id="method-i-process_aggregation" class="method-detail ">
|
381
|
+
|
382
|
+
<div class="method-heading">
|
383
|
+
<span class="method-name">process_aggregation</span><span
|
384
|
+
class="method-args">()</span>
|
385
|
+
|
386
|
+
<span class="method-click-advice">click to toggle source</span>
|
387
|
+
|
388
|
+
</div>
|
389
|
+
|
390
|
+
|
391
|
+
<div class="method-description">
|
392
|
+
|
393
|
+
<p>Process the aggregation of the key values</p>
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
<div class="method-source-code" id="process_aggregation-source">
|
399
|
+
<pre><span class="ruby-comment"># File lib/sycsvpro/aggregator.rb, line 59</span>
|
400
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">process_aggregation</span>
|
401
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">infile</span>).<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
|
402
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">col_filter</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">row_filter</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp</span>, <span class="ruby-identifier">row</span><span class="ruby-operator">:</span> <span class="ruby-identifier">index</span>))
|
403
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">empty?</span>
|
404
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">heading</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">and</span> <span class="ruby-keyword">not</span> <span class="ruby-identifier">headerless</span>
|
405
|
+
<span class="ruby-identifier">heading</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">';'</span>)
|
406
|
+
<span class="ruby-keyword">next</span>
|
407
|
+
<span class="ruby-keyword">else</span>
|
408
|
+
<span class="ruby-ivar">@sum_col</span> = [<span class="ruby-identifier">result</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">';'</span>).<span class="ruby-identifier">size</span>, <span class="ruby-identifier">sum_col</span>].<span class="ruby-identifier">max</span>
|
409
|
+
<span class="ruby-keyword">end</span>
|
410
|
+
<span class="ruby-identifier">key_values</span>[<span class="ruby-identifier">result</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
411
|
+
<span class="ruby-identifier">sums</span>[<span class="ruby-identifier">sum_col_title</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
412
|
+
<span class="ruby-keyword">end</span>
|
413
|
+
<span class="ruby-keyword">end</span>
|
414
|
+
<span class="ruby-identifier">heading</span>.<span class="ruby-identifier">flatten!</span>
|
415
|
+
<span class="ruby-identifier">heading</span>[<span class="ruby-identifier">sum_col</span>] = <span class="ruby-identifier">sum_col_title</span>
|
416
|
+
<span class="ruby-keyword">end</span></pre>
|
417
|
+
</div>
|
418
|
+
|
419
|
+
</div>
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
</div>
|
425
|
+
|
426
|
+
|
427
|
+
<div id="method-i-write_result" class="method-detail ">
|
428
|
+
|
429
|
+
<div class="method-heading">
|
430
|
+
<span class="method-name">write_result</span><span
|
431
|
+
class="method-args">()</span>
|
432
|
+
|
433
|
+
<span class="method-click-advice">click to toggle source</span>
|
434
|
+
|
435
|
+
</div>
|
436
|
+
|
437
|
+
|
438
|
+
<div class="method-description">
|
439
|
+
|
440
|
+
<p>Writes the aggration results</p>
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
<div class="method-source-code" id="write_result-source">
|
446
|
+
<pre><span class="ruby-comment"># File lib/sycsvpro/aggregator.rb, line 78</span>
|
447
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">write_result</span>
|
448
|
+
<span class="ruby-identifier">sum_line</span> = [<span class="ruby-identifier">sum_row_title</span>]
|
449
|
+
(<span class="ruby-identifier">heading</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span>).<span class="ruby-identifier">times</span> { <span class="ruby-identifier">sum_line</span> <span class="ruby-operator"><<</span> <span class="ruby-string">""</span> }
|
450
|
+
<span class="ruby-identifier">sum_line</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">sums</span>[<span class="ruby-identifier">sum_col_title</span>]
|
451
|
+
<span class="ruby-identifier">row</span> = <span class="ruby-value">0</span>;
|
452
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">outfile</span>, <span class="ruby-string">'w'</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
|
453
|
+
<span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">sum_line</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">';'</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">row</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">sum_row</span> ; <span class="ruby-identifier">row</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
454
|
+
<span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">heading</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">';'</span>)
|
455
|
+
<span class="ruby-identifier">key_values</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
456
|
+
<span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">sum_line</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">';'</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">row</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">sum_row</span> ; <span class="ruby-identifier">row</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
457
|
+
<span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> [<span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">';'</span>)
|
458
|
+
<span class="ruby-keyword">end</span>
|
459
|
+
<span class="ruby-keyword">end</span>
|
460
|
+
<span class="ruby-keyword">end</span></pre>
|
461
|
+
</div>
|
462
|
+
|
463
|
+
</div>
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
</div>
|
469
|
+
|
470
|
+
|
471
|
+
</section>
|
472
|
+
|
473
|
+
</section>
|
474
|
+
</main>
|
475
|
+
|
476
|
+
|
477
|
+
<footer id="validator-badges" role="contentinfo">
|
478
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
479
|
+
<p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
|
480
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
481
|
+
</footer>
|
482
|
+
|