sycsvpro 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39f66722b9a55455e899ca7a011b6d562f77854a
4
- data.tar.gz: 49ad0894d735625b689e904bedc50d551271ad7c
3
+ metadata.gz: 7f23ab9c0550c24e05e22e549f754313a15031af
4
+ data.tar.gz: c24f0803122979415fdbe3091e20bd4dfe2ba8cd
5
5
  SHA512:
6
- metadata.gz: b9761749882a98ab040eaba00e2e80c856341ead1b19cf2b897eb4a5a851af90740cd79bd2804f0c461ed87526a313a555b3877f11cf1a2902f1b1fcd1f8aaee
7
- data.tar.gz: 61654ae343a83fdfb87f531aa0c62c36eec85fd9aa0257863d99bfdbfeaff311e645d808782d48779c61b26a5acf015692aa71d2cf1c32b745b4065925c5962a
6
+ metadata.gz: 64f319161f670be8300684a313a4d91db1a2fd2e60d63249ab1d7d4557b68d028f48aaa657b02c5b687656bc4efad2317aae7b0e9c6551d416e2c0fb02737af8
7
+ data.tar.gz: 93c49e997231599193d4545e5a1fdc913e3768232df09c02439d2d3ea3c2a37424cafe9eface9c0aa1695686849de077aec0aa68acbc8f53fc287504117626e8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sycsvpro (0.0.7)
4
+ sycsvpro (0.0.9)
5
5
  gli (= 2.9.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -10,7 +10,7 @@ Processing of csv files. *sycsvpro* offers following functions
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
12
  * arithmetic operations on values of columns
13
- * sort rows base on columns
13
+ * sort rows base on columns (since version 0.0.9)
14
14
  * insert rows to a csv-file (since version 0.0.8)
15
15
  * create or edit a Ruby script
16
16
  * list scripts available optionally with methods (since version 0.0.7)
@@ -141,12 +141,15 @@ Sort rows on specified columns as an example sort rows based on customer (string
141
141
 
142
142
  $ sycsvpro -f in.csv -o out.csv sort -r 2-20 -c s:0,d:5
143
143
 
144
+ customer;machine;control;drive;motor;date;contract;target
144
145
  hello;h2;con123;dri130;mot110;1.02.3012;1
145
146
  hello;h1;con123;dri120;mot100;1.01.3013;1
146
147
  indix;i1;con456;dri130;mot090;5.11.3013;1
147
148
  chiro;c2;con331;dri100;mot130;3.05.3010;1
148
149
  chiro;c1;con333;dri110;mot100;1.10.3011;1
149
150
 
151
+ Sort expects the first non-empty row as the header row. If --headerless switch is set then sort assumes no header being available.
152
+
150
153
  Insert
151
154
  ------
152
155
  Add rows at the bottom or on top of a file. The command below adds the content of the file file-with-rows-to-insert.text on top of the file in.csv and saves it to out.csv
data/bin/sycsvpro CHANGED
@@ -33,6 +33,9 @@ desc 'CSV file to write the result to'
33
33
  arg_name 'OUT_FILE'
34
34
  flag [:o, :out]
35
35
 
36
+ desc 'Silent progress doesn\'t show progress indicator'
37
+ switch [:s, :silent]
38
+
36
39
  desc 'Analyze the CSV file regarding columns, rows and content'
37
40
  command :analyze do |c|
38
41
 
@@ -235,13 +238,16 @@ command :sort do |c|
235
238
  c.default_value '%Y-%m-%d'
236
239
  c.flag [:df]
237
240
 
241
+ c.desc 'File doesn\'t contain a header'
242
+ c.switch [:h, :headerless]
243
+
238
244
  c.desc 'Sort order descending - default ascending'
239
245
  c.switch [:d, :desc]
240
246
 
241
247
  c.action do |global_options,options,args|
242
248
  sorter = Sycsvpro::Sorter.new(infile: global_options[:f], outfile: global_options[:o],
243
249
  rows: options[:r], cols: options[:c], df: options[:df],
244
- desc: options[:d])
250
+ headerless: options[:h], desc: options[:d])
245
251
  print 'Sorting...'
246
252
  sorter.execute
247
253
  print 'done'
@@ -381,7 +387,7 @@ pre do |global,command,options,args|
381
387
 
382
388
  @stats = Stats.new(command.name, Time.now, Time.now, count)
383
389
 
384
- unless command.name == :edit
390
+ unless command.name == :edit or global[:s]
385
391
  progress = Thread.new do
386
392
  sleep 3
387
393
  while true
data/html/Dsl.html CHANGED
@@ -68,6 +68,8 @@
68
68
 
69
69
  <li ><a href="#method-i-rows">#rows</a>
70
70
 
71
+ <li ><a href="#method-i-str2utf8">#str2utf8</a>
72
+
71
73
  <li ><a href="#method-i-unstring">#unstring</a>
72
74
 
73
75
  <li ><a href="#method-i-write_to">#write_to</a>
@@ -151,6 +153,39 @@ provided by the caller</p>
151
153
 
152
154
 
153
155
 
156
+ </div>
157
+
158
+
159
+ <div id="method-i-str2utf8" class="method-detail ">
160
+
161
+ <div class="method-heading">
162
+ <span class="method-name">str2utf8</span><span
163
+ class="method-args">(str)</span>
164
+
165
+ <span class="method-click-advice">click to toggle source</span>
166
+
167
+ </div>
168
+
169
+
170
+ <div class="method-description">
171
+
172
+ <p>Remove non-UTF chars from string</p>
173
+
174
+
175
+
176
+
177
+ <div class="method-source-code" id="str2utf8-source">
178
+ <pre><span class="ruby-comment"># File lib/sycsvpro/dsl.rb, line 41</span>
179
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">str2utf8</span>(<span class="ruby-identifier">str</span>)
180
+ <span class="ruby-identifier">str</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-string">&#39;UTF-8&#39;</span>, <span class="ruby-string">&#39;binary&#39;</span>, <span class="ruby-identifier">invalid</span><span class="ruby-operator">:</span> <span class="ruby-value">:replace</span>, <span class="ruby-keyword">undef</span><span class="ruby-operator">:</span> <span class="ruby-value">:replace</span>, <span class="ruby-identifier">replace</span><span class="ruby-operator">:</span> <span class="ruby-string">&#39;&#39;</span>)
181
+ <span class="ruby-keyword">end</span></pre>
182
+ </div>
183
+
184
+ </div>
185
+
186
+
187
+
188
+
154
189
  </div>
155
190
 
156
191
 
@@ -168,8 +203,8 @@ provided by the caller</p>
168
203
  <div class="method-description">
169
204
 
170
205
  <p>Remove leading and trailing “ and spaces as well as reducing more than 2
171
- spaces between words from csv values like ”a“;ba g;c;”d“;e to a;b
172
- ag;c;d;e</p>
206
+ spaces between words from csv values. Replac ; with , from values as ; is
207
+ used as value separator</p>
173
208
 
174
209
 
175
210
 
@@ -177,6 +212,10 @@ ag;c;d;e</p>
177
212
  <div class="method-source-code" id="unstring-source">
178
213
  <pre><span class="ruby-comment"># File lib/sycsvpro/dsl.rb, line 32</span>
179
214
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">unstring</span>(<span class="ruby-identifier">line</span>)
215
+ <span class="ruby-identifier">line</span> = <span class="ruby-identifier">str2utf8</span>(<span class="ruby-identifier">line</span>)
216
+ <span class="ruby-identifier">line</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/(?&lt;=^&quot;|;&quot;)[^&quot;]+(?=;)+[^&quot;]*|;+[^&quot;](?=&quot;;|&quot;$)/</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
217
+ <span class="ruby-identifier">line</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">value</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">&#39;;&#39;</span>, <span class="ruby-string">&#39;,&#39;</span>))
218
+ <span class="ruby-keyword">end</span>
180
219
  <span class="ruby-identifier">line</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/(?&lt;=^|;)\s*&quot;?\s*|\s*&quot;?\s*(?=;|$)/</span>, <span class="ruby-string">&quot;&quot;</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/\s{2,}/</span>, <span class="ruby-string">&quot; &quot;</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">nil?</span>
181
220
  <span class="ruby-keyword">end</span></pre>
182
221
  </div>
@@ -134,12 +134,17 @@
134
134
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">options</span>={})
135
135
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">object</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">object</span>.<span class="ruby-identifier">empty?</span>
136
136
  <span class="ruby-identifier">object</span> = <span class="ruby-identifier">object</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-string">&#39;UTF-8&#39;</span>, <span class="ruby-string">&#39;binary&#39;</span>, <span class="ruby-identifier">invalid</span><span class="ruby-operator">:</span> <span class="ruby-value">:replace</span>, <span class="ruby-keyword">undef</span><span class="ruby-operator">:</span> <span class="ruby-value">:replace</span>, <span class="ruby-identifier">replace</span><span class="ruby-operator">:</span> <span class="ruby-string">&#39;&#39;</span>)
137
+ <span class="ruby-identifier">object</span> <span class="ruby-operator">+=</span> <span class="ruby-string">&quot; &quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">object</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/;$/</span>
137
138
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">object</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">filter</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">pivot</span>.<span class="ruby-identifier">empty?</span>
138
139
  <span class="ruby-identifier">filtered</span> = <span class="ruby-identifier">object</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&#39;;&#39;</span>).<span class="ruby-identifier">values_at</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">filter</span>.<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">uniq</span>)
139
140
  <span class="ruby-identifier">pivot_each_column</span>(<span class="ruby-identifier">object</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&#39;;&#39;</span>)) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">column</span>, <span class="ruby-identifier">match</span><span class="ruby-operator">|</span>
140
141
  <span class="ruby-identifier">filtered</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">column</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">match</span>
141
142
  <span class="ruby-keyword">end</span>
142
- <span class="ruby-identifier">filtered</span>.<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;;&#39;</span>)
143
+ <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">filtered</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">filtered</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">empty?</span>
144
+ <span class="ruby-identifier">filtered</span>.<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;;&#39;</span>) <span class="ruby-operator">+</span> <span class="ruby-string">&quot; &quot;</span>
145
+ <span class="ruby-keyword">else</span>
146
+ <span class="ruby-identifier">filtered</span>.<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;;&#39;</span>)
147
+ <span class="ruby-keyword">end</span>
143
148
  <span class="ruby-keyword">end</span></pre>
144
149
  </div>
145
150
 
@@ -152,10 +152,14 @@
152
152
  <span class="ruby-keyword">end</span>
153
153
  <span class="ruby-identifier">values</span>[<span class="ruby-identifier">index</span>] = <span class="ruby-identifier">number_value</span>
154
154
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">types</span>[<span class="ruby-identifier">index</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&#39;d&#39;</span>
155
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">empty?</span>
155
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">empty?</span>
156
156
  <span class="ruby-identifier">date</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">strptime</span>(<span class="ruby-string">&#39;9999-9-9&#39;</span>, <span class="ruby-string">&#39;%Y-%m-%d&#39;</span>)
157
157
  <span class="ruby-keyword">else</span>
158
- <span class="ruby-identifier">date</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">strptime</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">date_format</span>)
158
+ <span class="ruby-keyword">begin</span>
159
+ <span class="ruby-identifier">date</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">strptime</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">date_format</span>)
160
+ <span class="ruby-keyword">rescue</span>
161
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Error #{value}, #{index}&quot;</span>
162
+ <span class="ruby-keyword">end</span>
159
163
  <span class="ruby-keyword">end</span>
160
164
  <span class="ruby-identifier">values</span>[<span class="ruby-identifier">index</span>] = <span class="ruby-identifier">date</span>
161
165
  <span class="ruby-keyword">end</span>
@@ -148,6 +148,19 @@
148
148
  </div>
149
149
  </div>
150
150
 
151
+ <div id="attribute-i-headerless" class="method-detail">
152
+ <div class="method-heading attribute-method-heading">
153
+ <span class="method-name">headerless</span><span
154
+ class="attribute-access-type">[R]</span>
155
+ </div>
156
+
157
+ <div class="method-description">
158
+
159
+ <p>file doesn&#39;t contain a header</p>
160
+
161
+ </div>
162
+ </div>
163
+
151
164
  <div id="attribute-i-infile" class="method-detail">
152
165
  <div class="method-heading attribute-method-heading">
153
166
  <span class="method-name">infile</span><span
@@ -225,16 +238,17 @@
225
238
 
226
239
  <p>Creates a <a href="Sorter.html">Sorter</a> and takes as options infile,
227
240
  outfile, rows, cols including types and a date format for the date columns
228
- to sort (optional)</p>
241
+ to sort (optional).</p>
229
242
 
230
243
 
231
244
 
232
245
 
233
246
  <div class="method-source-code" id="new-source">
234
- <pre><span class="ruby-comment"># File lib/sycsvpro/sorter.rb, line 28</span>
247
+ <pre><span class="ruby-comment"># File lib/sycsvpro/sorter.rb, line 30</span>
235
248
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>={})
236
249
  <span class="ruby-ivar">@infile</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:infile</span>]
237
250
  <span class="ruby-ivar">@outfile</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:outfile</span>]
251
+ <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>
238
252
  <span class="ruby-ivar">@desc</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:desc</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword">false</span>
239
253
  <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>])
240
254
  <span class="ruby-ivar">@col_type_filter</span> = <span class="ruby-constant">ColumnTypeFilter</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>])
@@ -277,10 +291,15 @@ to sort (optional)</p>
277
291
 
278
292
 
279
293
  <div class="method-source-code" id="execute-source">
280
- <pre><span class="ruby-comment"># File lib/sycsvpro/sorter.rb, line 38</span>
294
+ <pre><span class="ruby-comment"># File lib/sycsvpro/sorter.rb, line 41</span>
281
295
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">execute</span>
282
296
  <span class="ruby-identifier">rows</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">readlines</span>(<span class="ruby-identifier">infile</span>)
283
297
 
298
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">headerless</span>
299
+ <span class="ruby-identifier">header</span> = <span class="ruby-string">&quot;&quot;</span>
300
+ <span class="ruby-identifier">header</span> = <span class="ruby-identifier">rows</span>.<span class="ruby-identifier">shift</span> <span class="ruby-keyword">while</span> <span class="ruby-identifier">header</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">empty?</span>
301
+ <span class="ruby-keyword">end</span>
302
+
284
303
  <span class="ruby-identifier">rows</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>
285
304
  <span class="ruby-identifier">filtered</span> = <span class="ruby-identifier">col_type_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">row</span><span class="ruby-operator">:</span> <span class="ruby-identifier">index</span>))
286
305
  <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">filtered</span>.<span class="ruby-identifier">nil?</span>
@@ -288,6 +307,10 @@ to sort (optional)</p>
288
307
  <span class="ruby-keyword">end</span>
289
308
 
290
309
  <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">outfile</span>, <span class="ruby-string">&#39;w&#39;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
310
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">headerless</span>
311
+ <span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">header</span>
312
+ <span class="ruby-keyword">end</span>
313
+
291
314
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">desc</span>
292
315
  <span class="ruby-identifier">sorted_rows</span>.<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">reverse</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span>
293
316
  <span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">unstring</span>(<span class="ruby-identifier">rows</span>[<span class="ruby-identifier">row</span>.<span class="ruby-identifier">last</span>])
data/html/created.rid CHANGED
@@ -1,14 +1,14 @@
1
- Wed, 26 Feb 2014 22:34:31 +0100
1
+ Sun, 02 Mar 2014 21:21:05 +0100
2
2
  README.rdoc Sun, 23 Feb 2014 19:23:16 +0100
3
3
  lib/sycsvpro.rb Wed, 26 Feb 2014 20:27:40 +0100
4
4
  lib/sycsvpro/allocator.rb Wed, 19 Feb 2014 20:34:28 +0100
5
5
  lib/sycsvpro/analyzer.rb Tue, 18 Feb 2014 19:57:28 +0100
6
6
  lib/sycsvpro/calculator.rb Tue, 18 Feb 2014 19:53:34 +0100
7
7
  lib/sycsvpro/collector.rb Sun, 16 Feb 2014 20:59:27 +0100
8
- lib/sycsvpro/column_filter.rb Tue, 25 Feb 2014 20:21:09 +0100
9
- lib/sycsvpro/column_type_filter.rb Wed, 26 Feb 2014 22:28:42 +0100
8
+ lib/sycsvpro/column_filter.rb Fri, 28 Feb 2014 08:24:47 +0100
9
+ lib/sycsvpro/column_type_filter.rb Fri, 28 Feb 2014 18:17:46 +0100
10
10
  lib/sycsvpro/counter.rb Fri, 21 Feb 2014 21:11:49 +0100
11
- lib/sycsvpro/dsl.rb Tue, 18 Feb 2014 21:34:51 +0100
11
+ lib/sycsvpro/dsl.rb Sun, 02 Mar 2014 17:59:05 +0100
12
12
  lib/sycsvpro/extractor.rb Sat, 22 Feb 2014 17:58:18 +0100
13
13
  lib/sycsvpro/filter.rb Tue, 25 Feb 2014 21:18:25 +0100
14
14
  lib/sycsvpro/header.rb Tue, 18 Feb 2014 19:50:26 +0100
@@ -18,6 +18,6 @@ lib/sycsvpro/profiler.rb Sun, 16 Feb 2014 21:31:39 +0100
18
18
  lib/sycsvpro/row_filter.rb Tue, 18 Feb 2014 19:45:25 +0100
19
19
  lib/sycsvpro/script_creator.rb Sun, 23 Feb 2014 20:35:21 +0100
20
20
  lib/sycsvpro/script_list.rb Sun, 23 Feb 2014 21:03:22 +0100
21
- lib/sycsvpro/sorter.rb Wed, 26 Feb 2014 08:56:58 +0100
22
- lib/sycsvpro/version.rb Sun, 23 Feb 2014 13:57:16 +0100
23
- bin/sycsvpro Wed, 26 Feb 2014 21:31:44 +0100
21
+ lib/sycsvpro/sorter.rb Sun, 02 Mar 2014 21:07:30 +0100
22
+ lib/sycsvpro/version.rb Fri, 28 Feb 2014 08:30:53 +0100
23
+ bin/sycsvpro Sun, 02 Mar 2014 20:54:54 +0100
@@ -1 +1 @@
1
- var search_data = {"index":{"searchIndex":["dsl","object","sycsvpro","allocator","analyzer","calculator","collector","columnfilter","columntypefilter","counter","extractor","filter","header","inserter","mapper","profiler","rowfilter","scriptcreator","scriptlist","sorter","execute()","execute()","execute()","execute()","execute()","execute()","execute()","execute()","execute()","execute()","has_filter?()","method_missing()","method_missing()","new()","new()","new()","new()","new()","new()","new()","new()","new()","new()","new()","new()","new()","new()","pivot_each_column()","process()","process()","process()","process()","process()","process_file()","result()","rows()","unstring()","write_result()","write_to()","readme"],"longSearchIndex":["dsl","object","sycsvpro","sycsvpro::allocator","sycsvpro::analyzer","sycsvpro::calculator","sycsvpro::collector","sycsvpro::columnfilter","sycsvpro::columntypefilter","sycsvpro::counter","sycsvpro::extractor","sycsvpro::filter","sycsvpro::header","sycsvpro::inserter","sycsvpro::mapper","sycsvpro::profiler","sycsvpro::rowfilter","sycsvpro::scriptcreator","sycsvpro::scriptlist","sycsvpro::sorter","sycsvpro::allocator#execute()","sycsvpro::calculator#execute()","sycsvpro::collector#execute()","sycsvpro::counter#execute()","sycsvpro::extractor#execute()","sycsvpro::inserter#execute()","sycsvpro::mapper#execute()","sycsvpro::profiler#execute()","sycsvpro::scriptlist#execute()","sycsvpro::sorter#execute()","sycsvpro::filter#has_filter?()","sycsvpro::calculator#method_missing()","sycsvpro::filter#method_missing()","sycsvpro::allocator::new()","sycsvpro::analyzer::new()","sycsvpro::calculator::new()","sycsvpro::collector::new()","sycsvpro::counter::new()","sycsvpro::extractor::new()","sycsvpro::filter::new()","sycsvpro::header::new()","sycsvpro::inserter::new()","sycsvpro::mapper::new()","sycsvpro::profiler::new()","sycsvpro::scriptcreator::new()","sycsvpro::scriptlist::new()","sycsvpro::sorter::new()","sycsvpro::filter#pivot_each_column()","sycsvpro::columnfilter#process()","sycsvpro::columntypefilter#process()","sycsvpro::filter#process()","sycsvpro::header#process()","sycsvpro::rowfilter#process()","sycsvpro::counter#process_file()","sycsvpro::analyzer#result()","dsl#rows()","dsl#unstring()","sycsvpro::counter#write_result()","dsl#write_to()",""],"info":[["Dsl","","Dsl.html","","<p>Methods to be used in customer specific script files\n"],["Object","","Object.html","",""],["Sycsvpro","","Sycsvpro.html","","<p>Operating csv files\n<p>Operating csv files\n<p>Operating csv files\n"],["Sycsvpro::Allocator","","Sycsvpro/Allocator.html","","<p>Allocates columns to a key column\n"],["Sycsvpro::Analyzer","","Sycsvpro/Analyzer.html","","<p>Analyzes the file structure\n"],["Sycsvpro::Calculator","","Sycsvpro/Calculator.html","","<p>Processes arithmetic operations on columns of a csv file. A column value\nhas to be a number. Possible …\n"],["Sycsvpro::Collector","","Sycsvpro/Collector.html","","<p>Collects values from rows and groups them in categories\n"],["Sycsvpro::ColumnFilter","","Sycsvpro/ColumnFilter.html","","<p>Creates a new column filter\n"],["Sycsvpro::ColumnTypeFilter","","Sycsvpro/ColumnTypeFilter.html","","<p>Create a filter based on a colum and its type\n"],["Sycsvpro::Counter","","Sycsvpro/Counter.html","","<p>Creates a new counter that counts values and uses the values as column\nnames and uses the count as the …\n"],["Sycsvpro::Extractor","","Sycsvpro/Extractor.html","","<p>Extracts rows and columns from a csv file\n"],["Sycsvpro::Filter","","Sycsvpro/Filter.html","","<p>Creates a new filter that can be extended by sub-classes. A sub-class needs\nto override the process method …\n"],["Sycsvpro::Header","","Sycsvpro/Header.html","","<p>Creates a header\n"],["Sycsvpro::Inserter","","Sycsvpro/Inserter.html","","<p>Insert a text file into another textfile at a specified position\n"],["Sycsvpro::Mapper","","Sycsvpro/Mapper.html","","<p>Map values to new values described in a mapping file\n"],["Sycsvpro::Profiler","","Sycsvpro/Profiler.html","","<p>A profiler takes a Ruby script and executes the provided method in the\nscript\n"],["Sycsvpro::RowFilter","","Sycsvpro/RowFilter.html","","<p>Filters rows based on provided patterns\n"],["Sycsvpro::ScriptCreator","","Sycsvpro/ScriptCreator.html","","<p>Creates a ruby script scaffold\n"],["Sycsvpro::ScriptList","","Sycsvpro/ScriptList.html","","<p>Lists the contents of the script directory. Optionally listing a specific\nscript file and also optionally …\n"],["Sycsvpro::Sorter","","Sycsvpro/Sorter.html","","<p>Sorts an input file based on a column sort filter\n"],["execute","Sycsvpro::Allocator","Sycsvpro/Allocator.html#method-i-execute","()","<p>Executes the allocator and assigns column values to the key\n"],["execute","Sycsvpro::Calculator","Sycsvpro/Calculator.html#method-i-execute","()","<p>Executes the calculator\n"],["execute","Sycsvpro::Collector","Sycsvpro/Collector.html#method-i-execute","()","<p>Execute the collector\n"],["execute","Sycsvpro::Counter","Sycsvpro/Counter.html#method-i-execute","()","<p>Executes the counter\n"],["execute","Sycsvpro::Extractor","Sycsvpro/Extractor.html#method-i-execute","()","<p>Executes the extractor\n"],["execute","Sycsvpro::Inserter","Sycsvpro/Inserter.html#method-i-execute","()","<p>Inserts the content of the insert-file at the specified positions (top or\nbottom)\n"],["execute","Sycsvpro::Mapper","Sycsvpro/Mapper.html#method-i-execute","()","<p>Executes the mapper\n"],["execute","Sycsvpro::Profiler","Sycsvpro/Profiler.html#method-i-execute","(method)","<p>Executes the provided method in the Ruby script\n"],["execute","Sycsvpro::ScriptList","Sycsvpro/ScriptList.html#method-i-execute","()","<p>Retrieves the information about scripts and methods from the script\ndirectory\n"],["execute","Sycsvpro::Sorter","Sycsvpro/Sorter.html#method-i-execute","()","<p>Sorts the data of the infile\n"],["has_filter?","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-has_filter-3F","()","<p>Checks whether a filter has been set. Returns true if filter has been set\notherwise false\n"],["method_missing","Sycsvpro::Calculator","Sycsvpro/Calculator.html#method-i-method_missing","(id, *args, &block)","<p>Retrieves the values from a row as the result of a arithmetic operation\n"],["method_missing","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-method_missing","(id, *args, &block)","<p>Creates the filters based on the given patterns\n"],["new","Sycsvpro::Allocator","Sycsvpro/Allocator.html#method-c-new","(options={})","<p>Creates a new allocator. Options are infile, outfile, key, rows and columns\nto allocate to key\n"],["new","Sycsvpro::Analyzer","Sycsvpro/Analyzer.html#method-c-new","(file)","<p>Creates a new analyzer\n"],["new","Sycsvpro::Calculator","Sycsvpro/Calculator.html#method-c-new","(options={})","<p>Creates a new Calculator. Options expects :infile, :outfile, :rows and\n:columns. Optionally a header …\n"],["new","Sycsvpro::Collector","Sycsvpro/Collector.html#method-c-new","(options={})","<p>Creates a new Collector\n"],["new","Sycsvpro::Counter","Sycsvpro/Counter.html#method-c-new","(options={})","<p>Creates a new counter. Takes as attributes infile, outfile, key, rows,\ncols, date-format and indicator …\n"],["new","Sycsvpro::Extractor","Sycsvpro/Extractor.html#method-c-new","(options={})","<p>Creates a new extractor\n"],["new","Sycsvpro::Filter","Sycsvpro/Filter.html#method-c-new","(values, options={})","<p>Creates a new filter\n"],["new","Sycsvpro::Header","Sycsvpro/Header.html#method-c-new","(header)","<p>Create a new header\n"],["new","Sycsvpro::Inserter","Sycsvpro/Inserter.html#method-c-new","(options={})","<p>Creates an Inserter and takes options infile, outfile, insert-file and\nposition where to insert the insert-file …\n"],["new","Sycsvpro::Mapper","Sycsvpro/Mapper.html#method-c-new","(options={})","<p>Creates new mapper\n"],["new","Sycsvpro::Profiler","Sycsvpro/Profiler.html#method-c-new","(pro_file)","<p>Creates a new profiler\n"],["new","Sycsvpro::ScriptCreator","Sycsvpro/ScriptCreator.html#method-c-new","(options={})","<p>Creates a new ScriptCreator\n"],["new","Sycsvpro::ScriptList","Sycsvpro/ScriptList.html#method-c-new","(options={})","<p>Creates a new ScriptList. Takes params script_dir, script_file and\nshow_methods\n"],["new","Sycsvpro::Sorter","Sycsvpro/Sorter.html#method-c-new","(options={})","<p>Creates a Sorter and takes as options infile, outfile, rows, cols including\ntypes and a date format for …\n"],["pivot_each_column","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-pivot_each_column","(values=[])","<p>Yields the column value and whether the filter matches the column\n"],["process","Sycsvpro::ColumnFilter","Sycsvpro/ColumnFilter.html#method-i-process","(object, options={})","<p>Processes the filter and returns the values that respect the filter\n"],["process","Sycsvpro::ColumnTypeFilter","Sycsvpro/ColumnTypeFilter.html#method-i-process","(object, options={})","<p>Processes the filter and returns the filtered columns\n"],["process","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-process","(object, options={})","<p>Processes the filter. Needs to be overridden by the sub-class\n"],["process","Sycsvpro::Header","Sycsvpro/Header.html#method-i-process","(line)","<p>Returns the header\n"],["process","Sycsvpro::RowFilter","Sycsvpro/RowFilter.html#method-i-process","(object, options={})","<p>Processes the filter on the given row\n"],["process_file","Sycsvpro::Counter","Sycsvpro/Counter.html#method-i-process_file","()","<p>Processes the counting on the in file\n"],["result","Sycsvpro::Analyzer","Sycsvpro/Analyzer.html#method-i-result","()","<p>Analyzes the file and returns the result\n"],["rows","Dsl","Dsl.html#method-i-rows","(options={})","<p>Retrieves rows and columns from the file and returns them to the block\nprovided by the caller\n"],["unstring","Dsl","Dsl.html#method-i-unstring","(line)","<p>Remove leading and trailing “ and spaces as well as reducing more than 2\nspaces between words from …\n"],["write_result","Sycsvpro::Counter","Sycsvpro/Counter.html#method-i-write_result","()","<p>Writes the results\n"],["write_to","Dsl","Dsl.html#method-i-write_to","(file)","<p>writes values provided by a block to the given file\n"],["README","","README_rdoc.html","","<p>sycsvpro\n<p>Author &mdash; Pierre Sugar (pierre@sugaryourcoffee.de)\n<p>Copyright &mdash; Copyright © 2014 by Pierre Sugar\n"]]}}
1
+ var search_data = {"index":{"searchIndex":["dsl","object","sycsvpro","allocator","analyzer","calculator","collector","columnfilter","columntypefilter","counter","extractor","filter","header","inserter","mapper","profiler","rowfilter","scriptcreator","scriptlist","sorter","execute()","execute()","execute()","execute()","execute()","execute()","execute()","execute()","execute()","execute()","has_filter?()","method_missing()","method_missing()","new()","new()","new()","new()","new()","new()","new()","new()","new()","new()","new()","new()","new()","new()","pivot_each_column()","process()","process()","process()","process()","process()","process_file()","result()","rows()","str2utf8()","unstring()","write_result()","write_to()","readme"],"longSearchIndex":["dsl","object","sycsvpro","sycsvpro::allocator","sycsvpro::analyzer","sycsvpro::calculator","sycsvpro::collector","sycsvpro::columnfilter","sycsvpro::columntypefilter","sycsvpro::counter","sycsvpro::extractor","sycsvpro::filter","sycsvpro::header","sycsvpro::inserter","sycsvpro::mapper","sycsvpro::profiler","sycsvpro::rowfilter","sycsvpro::scriptcreator","sycsvpro::scriptlist","sycsvpro::sorter","sycsvpro::allocator#execute()","sycsvpro::calculator#execute()","sycsvpro::collector#execute()","sycsvpro::counter#execute()","sycsvpro::extractor#execute()","sycsvpro::inserter#execute()","sycsvpro::mapper#execute()","sycsvpro::profiler#execute()","sycsvpro::scriptlist#execute()","sycsvpro::sorter#execute()","sycsvpro::filter#has_filter?()","sycsvpro::calculator#method_missing()","sycsvpro::filter#method_missing()","sycsvpro::allocator::new()","sycsvpro::analyzer::new()","sycsvpro::calculator::new()","sycsvpro::collector::new()","sycsvpro::counter::new()","sycsvpro::extractor::new()","sycsvpro::filter::new()","sycsvpro::header::new()","sycsvpro::inserter::new()","sycsvpro::mapper::new()","sycsvpro::profiler::new()","sycsvpro::scriptcreator::new()","sycsvpro::scriptlist::new()","sycsvpro::sorter::new()","sycsvpro::filter#pivot_each_column()","sycsvpro::columnfilter#process()","sycsvpro::columntypefilter#process()","sycsvpro::filter#process()","sycsvpro::header#process()","sycsvpro::rowfilter#process()","sycsvpro::counter#process_file()","sycsvpro::analyzer#result()","dsl#rows()","dsl#str2utf8()","dsl#unstring()","sycsvpro::counter#write_result()","dsl#write_to()",""],"info":[["Dsl","","Dsl.html","","<p>Methods to be used in customer specific script files\n"],["Object","","Object.html","",""],["Sycsvpro","","Sycsvpro.html","","<p>Operating csv files\n<p>Operating csv files\n<p>Operating csv files\n"],["Sycsvpro::Allocator","","Sycsvpro/Allocator.html","","<p>Allocates columns to a key column\n"],["Sycsvpro::Analyzer","","Sycsvpro/Analyzer.html","","<p>Analyzes the file structure\n"],["Sycsvpro::Calculator","","Sycsvpro/Calculator.html","","<p>Processes arithmetic operations on columns of a csv file. A column value\nhas to be a number. Possible …\n"],["Sycsvpro::Collector","","Sycsvpro/Collector.html","","<p>Collects values from rows and groups them in categories\n"],["Sycsvpro::ColumnFilter","","Sycsvpro/ColumnFilter.html","","<p>Creates a new column filter\n"],["Sycsvpro::ColumnTypeFilter","","Sycsvpro/ColumnTypeFilter.html","","<p>Create a filter based on a colum and its type\n"],["Sycsvpro::Counter","","Sycsvpro/Counter.html","","<p>Creates a new counter that counts values and uses the values as column\nnames and uses the count as the …\n"],["Sycsvpro::Extractor","","Sycsvpro/Extractor.html","","<p>Extracts rows and columns from a csv file\n"],["Sycsvpro::Filter","","Sycsvpro/Filter.html","","<p>Creates a new filter that can be extended by sub-classes. A sub-class needs\nto override the process method …\n"],["Sycsvpro::Header","","Sycsvpro/Header.html","","<p>Creates a header\n"],["Sycsvpro::Inserter","","Sycsvpro/Inserter.html","","<p>Insert a text file into another textfile at a specified position\n"],["Sycsvpro::Mapper","","Sycsvpro/Mapper.html","","<p>Map values to new values described in a mapping file\n"],["Sycsvpro::Profiler","","Sycsvpro/Profiler.html","","<p>A profiler takes a Ruby script and executes the provided method in the\nscript\n"],["Sycsvpro::RowFilter","","Sycsvpro/RowFilter.html","","<p>Filters rows based on provided patterns\n"],["Sycsvpro::ScriptCreator","","Sycsvpro/ScriptCreator.html","","<p>Creates a ruby script scaffold\n"],["Sycsvpro::ScriptList","","Sycsvpro/ScriptList.html","","<p>Lists the contents of the script directory. Optionally listing a specific\nscript file and also optionally …\n"],["Sycsvpro::Sorter","","Sycsvpro/Sorter.html","","<p>Sorts an input file based on a column sort filter\n"],["execute","Sycsvpro::Allocator","Sycsvpro/Allocator.html#method-i-execute","()","<p>Executes the allocator and assigns column values to the key\n"],["execute","Sycsvpro::Calculator","Sycsvpro/Calculator.html#method-i-execute","()","<p>Executes the calculator\n"],["execute","Sycsvpro::Collector","Sycsvpro/Collector.html#method-i-execute","()","<p>Execute the collector\n"],["execute","Sycsvpro::Counter","Sycsvpro/Counter.html#method-i-execute","()","<p>Executes the counter\n"],["execute","Sycsvpro::Extractor","Sycsvpro/Extractor.html#method-i-execute","()","<p>Executes the extractor\n"],["execute","Sycsvpro::Inserter","Sycsvpro/Inserter.html#method-i-execute","()","<p>Inserts the content of the insert-file at the specified positions (top or\nbottom)\n"],["execute","Sycsvpro::Mapper","Sycsvpro/Mapper.html#method-i-execute","()","<p>Executes the mapper\n"],["execute","Sycsvpro::Profiler","Sycsvpro/Profiler.html#method-i-execute","(method)","<p>Executes the provided method in the Ruby script\n"],["execute","Sycsvpro::ScriptList","Sycsvpro/ScriptList.html#method-i-execute","()","<p>Retrieves the information about scripts and methods from the script\ndirectory\n"],["execute","Sycsvpro::Sorter","Sycsvpro/Sorter.html#method-i-execute","()","<p>Sorts the data of the infile\n"],["has_filter?","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-has_filter-3F","()","<p>Checks whether a filter has been set. Returns true if filter has been set\notherwise false\n"],["method_missing","Sycsvpro::Calculator","Sycsvpro/Calculator.html#method-i-method_missing","(id, *args, &block)","<p>Retrieves the values from a row as the result of a arithmetic operation\n"],["method_missing","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-method_missing","(id, *args, &block)","<p>Creates the filters based on the given patterns\n"],["new","Sycsvpro::Allocator","Sycsvpro/Allocator.html#method-c-new","(options={})","<p>Creates a new allocator. Options are infile, outfile, key, rows and columns\nto allocate to key\n"],["new","Sycsvpro::Analyzer","Sycsvpro/Analyzer.html#method-c-new","(file)","<p>Creates a new analyzer\n"],["new","Sycsvpro::Calculator","Sycsvpro/Calculator.html#method-c-new","(options={})","<p>Creates a new Calculator. Options expects :infile, :outfile, :rows and\n:columns. Optionally a header …\n"],["new","Sycsvpro::Collector","Sycsvpro/Collector.html#method-c-new","(options={})","<p>Creates a new Collector\n"],["new","Sycsvpro::Counter","Sycsvpro/Counter.html#method-c-new","(options={})","<p>Creates a new counter. Takes as attributes infile, outfile, key, rows,\ncols, date-format and indicator …\n"],["new","Sycsvpro::Extractor","Sycsvpro/Extractor.html#method-c-new","(options={})","<p>Creates a new extractor\n"],["new","Sycsvpro::Filter","Sycsvpro/Filter.html#method-c-new","(values, options={})","<p>Creates a new filter\n"],["new","Sycsvpro::Header","Sycsvpro/Header.html#method-c-new","(header)","<p>Create a new header\n"],["new","Sycsvpro::Inserter","Sycsvpro/Inserter.html#method-c-new","(options={})","<p>Creates an Inserter and takes options infile, outfile, insert-file and\nposition where to insert the insert-file …\n"],["new","Sycsvpro::Mapper","Sycsvpro/Mapper.html#method-c-new","(options={})","<p>Creates new mapper\n"],["new","Sycsvpro::Profiler","Sycsvpro/Profiler.html#method-c-new","(pro_file)","<p>Creates a new profiler\n"],["new","Sycsvpro::ScriptCreator","Sycsvpro/ScriptCreator.html#method-c-new","(options={})","<p>Creates a new ScriptCreator\n"],["new","Sycsvpro::ScriptList","Sycsvpro/ScriptList.html#method-c-new","(options={})","<p>Creates a new ScriptList. Takes params script_dir, script_file and\nshow_methods\n"],["new","Sycsvpro::Sorter","Sycsvpro/Sorter.html#method-c-new","(options={})","<p>Creates a Sorter and takes as options infile, outfile, rows, cols including\ntypes and a date format for …\n"],["pivot_each_column","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-pivot_each_column","(values=[])","<p>Yields the column value and whether the filter matches the column\n"],["process","Sycsvpro::ColumnFilter","Sycsvpro/ColumnFilter.html#method-i-process","(object, options={})","<p>Processes the filter and returns the values that respect the filter\n"],["process","Sycsvpro::ColumnTypeFilter","Sycsvpro/ColumnTypeFilter.html#method-i-process","(object, options={})","<p>Processes the filter and returns the filtered columns\n"],["process","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-process","(object, options={})","<p>Processes the filter. Needs to be overridden by the sub-class\n"],["process","Sycsvpro::Header","Sycsvpro/Header.html#method-i-process","(line)","<p>Returns the header\n"],["process","Sycsvpro::RowFilter","Sycsvpro/RowFilter.html#method-i-process","(object, options={})","<p>Processes the filter on the given row\n"],["process_file","Sycsvpro::Counter","Sycsvpro/Counter.html#method-i-process_file","()","<p>Processes the counting on the in file\n"],["result","Sycsvpro::Analyzer","Sycsvpro/Analyzer.html#method-i-result","()","<p>Analyzes the file and returns the result\n"],["rows","Dsl","Dsl.html#method-i-rows","(options={})","<p>Retrieves rows and columns from the file and returns them to the block\nprovided by the caller\n"],["str2utf8","Dsl","Dsl.html#method-i-str2utf8","(str)","<p>Remove non-UTF chars from string\n"],["unstring","Dsl","Dsl.html#method-i-unstring","(line)","<p>Remove leading and trailing “ and spaces as well as reducing more than 2\nspaces between words from …\n"],["write_result","Sycsvpro::Counter","Sycsvpro/Counter.html#method-i-write_result","()","<p>Writes the results\n"],["write_to","Dsl","Dsl.html#method-i-write_to","(file)","<p>writes values provided by a block to the given file\n"],["README","","README_rdoc.html","","<p>sycsvpro\n<p>Author &mdash; Pierre Sugar (pierre@sugaryourcoffee.de)\n<p>Copyright &mdash; Copyright © 2014 by Pierre Sugar\n"]]}}
@@ -114,9 +114,9 @@
114
114
  <span class="container">Sycsvpro::Allocator</span>
115
115
 
116
116
  <li class="method">
117
- <a href="Sycsvpro/Profiler.html#method-c-new">::new</a>
117
+ <a href="Sycsvpro/Mapper.html#method-c-new">::new</a>
118
118
  &mdash;
119
- <span class="container">Sycsvpro::Profiler</span>
119
+ <span class="container">Sycsvpro::Mapper</span>
120
120
 
121
121
  <li class="method">
122
122
  <a href="Sycsvpro/Analyzer.html#method-c-new">::new</a>
@@ -124,9 +124,9 @@
124
124
  <span class="container">Sycsvpro::Analyzer</span>
125
125
 
126
126
  <li class="method">
127
- <a href="Sycsvpro/Mapper.html#method-c-new">::new</a>
127
+ <a href="Sycsvpro/Inserter.html#method-c-new">::new</a>
128
128
  &mdash;
129
- <span class="container">Sycsvpro::Mapper</span>
129
+ <span class="container">Sycsvpro::Inserter</span>
130
130
 
131
131
  <li class="method">
132
132
  <a href="Sycsvpro/Calculator.html#method-c-new">::new</a>
@@ -134,9 +134,9 @@
134
134
  <span class="container">Sycsvpro::Calculator</span>
135
135
 
136
136
  <li class="method">
137
- <a href="Sycsvpro/Inserter.html#method-c-new">::new</a>
137
+ <a href="Sycsvpro/Profiler.html#method-c-new">::new</a>
138
138
  &mdash;
139
- <span class="container">Sycsvpro::Inserter</span>
139
+ <span class="container">Sycsvpro::Profiler</span>
140
140
 
141
141
  <li class="method">
142
142
  <a href="Sycsvpro/Header.html#method-c-new">::new</a>
@@ -148,11 +148,6 @@
148
148
  &mdash;
149
149
  <span class="container">Sycsvpro::Collector</span>
150
150
 
151
- <li class="method">
152
- <a href="Sycsvpro/ScriptList.html#method-c-new">::new</a>
153
- &mdash;
154
- <span class="container">Sycsvpro::ScriptList</span>
155
-
156
151
  <li class="method">
157
152
  <a href="Sycsvpro/Filter.html#method-c-new">::new</a>
158
153
  &mdash;
@@ -164,14 +159,14 @@
164
159
  <span class="container">Sycsvpro::Sorter</span>
165
160
 
166
161
  <li class="method">
167
- <a href="Sycsvpro/Counter.html#method-c-new">::new</a>
162
+ <a href="Sycsvpro/Extractor.html#method-c-new">::new</a>
168
163
  &mdash;
169
- <span class="container">Sycsvpro::Counter</span>
164
+ <span class="container">Sycsvpro::Extractor</span>
170
165
 
171
166
  <li class="method">
172
- <a href="Sycsvpro/Extractor.html#method-c-new">::new</a>
167
+ <a href="Sycsvpro/Counter.html#method-c-new">::new</a>
173
168
  &mdash;
174
- <span class="container">Sycsvpro::Extractor</span>
169
+ <span class="container">Sycsvpro::Counter</span>
175
170
 
176
171
  <li class="method">
177
172
  <a href="Sycsvpro/ScriptCreator.html#method-c-new">::new</a>
@@ -179,7 +174,7 @@
179
174
  <span class="container">Sycsvpro::ScriptCreator</span>
180
175
 
181
176
  <li class="method">
182
- <a href="Sycsvpro/ScriptList.html#method-i-execute">#execute</a>
177
+ <a href="Sycsvpro/ScriptList.html#method-c-new">::new</a>
183
178
  &mdash;
184
179
  <span class="container">Sycsvpro::ScriptList</span>
185
180
 
@@ -189,24 +184,29 @@
189
184
  <span class="container">Sycsvpro::Counter</span>
190
185
 
191
186
  <li class="method">
192
- <a href="Sycsvpro/Profiler.html#method-i-execute">#execute</a>
187
+ <a href="Sycsvpro/ScriptList.html#method-i-execute">#execute</a>
193
188
  &mdash;
194
- <span class="container">Sycsvpro::Profiler</span>
189
+ <span class="container">Sycsvpro::ScriptList</span>
195
190
 
196
191
  <li class="method">
197
- <a href="Sycsvpro/Allocator.html#method-i-execute">#execute</a>
192
+ <a href="Sycsvpro/Extractor.html#method-i-execute">#execute</a>
198
193
  &mdash;
199
- <span class="container">Sycsvpro::Allocator</span>
194
+ <span class="container">Sycsvpro::Extractor</span>
200
195
 
201
196
  <li class="method">
202
- <a href="Sycsvpro/Mapper.html#method-i-execute">#execute</a>
197
+ <a href="Sycsvpro/Collector.html#method-i-execute">#execute</a>
203
198
  &mdash;
204
- <span class="container">Sycsvpro::Mapper</span>
199
+ <span class="container">Sycsvpro::Collector</span>
205
200
 
206
201
  <li class="method">
207
- <a href="Sycsvpro/Collector.html#method-i-execute">#execute</a>
202
+ <a href="Sycsvpro/Allocator.html#method-i-execute">#execute</a>
208
203
  &mdash;
209
- <span class="container">Sycsvpro::Collector</span>
204
+ <span class="container">Sycsvpro::Allocator</span>
205
+
206
+ <li class="method">
207
+ <a href="Sycsvpro/Profiler.html#method-i-execute">#execute</a>
208
+ &mdash;
209
+ <span class="container">Sycsvpro::Profiler</span>
210
210
 
211
211
  <li class="method">
212
212
  <a href="Sycsvpro/Sorter.html#method-i-execute">#execute</a>
@@ -224,9 +224,9 @@
224
224
  <span class="container">Sycsvpro::Calculator</span>
225
225
 
226
226
  <li class="method">
227
- <a href="Sycsvpro/Extractor.html#method-i-execute">#execute</a>
227
+ <a href="Sycsvpro/Mapper.html#method-i-execute">#execute</a>
228
228
  &mdash;
229
- <span class="container">Sycsvpro::Extractor</span>
229
+ <span class="container">Sycsvpro::Mapper</span>
230
230
 
231
231
  <li class="method">
232
232
  <a href="Sycsvpro/Filter.html#method-i-has_filter-3F">#has_filter?</a>
@@ -249,14 +249,14 @@
249
249
  <span class="container">Sycsvpro::Filter</span>
250
250
 
251
251
  <li class="method">
252
- <a href="Sycsvpro/ColumnFilter.html#method-i-process">#process</a>
252
+ <a href="Sycsvpro/Header.html#method-i-process">#process</a>
253
253
  &mdash;
254
- <span class="container">Sycsvpro::ColumnFilter</span>
254
+ <span class="container">Sycsvpro::Header</span>
255
255
 
256
256
  <li class="method">
257
- <a href="Sycsvpro/ColumnTypeFilter.html#method-i-process">#process</a>
257
+ <a href="Sycsvpro/Filter.html#method-i-process">#process</a>
258
258
  &mdash;
259
- <span class="container">Sycsvpro::ColumnTypeFilter</span>
259
+ <span class="container">Sycsvpro::Filter</span>
260
260
 
261
261
  <li class="method">
262
262
  <a href="Sycsvpro/RowFilter.html#method-i-process">#process</a>
@@ -264,14 +264,14 @@
264
264
  <span class="container">Sycsvpro::RowFilter</span>
265
265
 
266
266
  <li class="method">
267
- <a href="Sycsvpro/Header.html#method-i-process">#process</a>
267
+ <a href="Sycsvpro/ColumnTypeFilter.html#method-i-process">#process</a>
268
268
  &mdash;
269
- <span class="container">Sycsvpro::Header</span>
269
+ <span class="container">Sycsvpro::ColumnTypeFilter</span>
270
270
 
271
271
  <li class="method">
272
- <a href="Sycsvpro/Filter.html#method-i-process">#process</a>
272
+ <a href="Sycsvpro/ColumnFilter.html#method-i-process">#process</a>
273
273
  &mdash;
274
- <span class="container">Sycsvpro::Filter</span>
274
+ <span class="container">Sycsvpro::ColumnFilter</span>
275
275
 
276
276
  <li class="method">
277
277
  <a href="Sycsvpro/Counter.html#method-i-process_file">#process_file</a>
@@ -288,6 +288,11 @@
288
288
  &mdash;
289
289
  <span class="container">Dsl</span>
290
290
 
291
+ <li class="method">
292
+ <a href="Dsl.html#method-i-str2utf8">#str2utf8</a>
293
+ &mdash;
294
+ <span class="container">Dsl</span>
295
+
291
296
  <li class="method">
292
297
  <a href="Dsl.html#method-i-unstring">#unstring</a>
293
298
  &mdash;
@@ -10,12 +10,17 @@ module Sycsvpro
10
10
  def process(object, options={})
11
11
  return nil if object.nil? or object.empty?
12
12
  object = object.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
13
+ object += " " if object =~ /;$/
13
14
  return object if filter.empty? and pivot.empty?
14
15
  filtered = object.split(';').values_at(*filter.flatten.uniq)
15
16
  pivot_each_column(object.split(';')) do |column, match|
16
17
  filtered << column if match
17
18
  end
18
- filtered.compact.join(';')
19
+ if !filtered.last.nil? and filtered.last.empty?
20
+ filtered.compact.join(';') + " "
21
+ else
22
+ filtered.compact.join(';')
23
+ end
19
24
  end
20
25
 
21
26
  end
@@ -21,10 +21,14 @@ module Sycsvpro
21
21
  end
22
22
  values[index] = number_value
23
23
  elsif types[index] == 'd'
24
- if value.empty?
24
+ if value.strip.empty?
25
25
  date = Date.strptime('9999-9-9', '%Y-%m-%d')
26
26
  else
27
- date = Date.strptime(value, date_format)
27
+ begin
28
+ date = Date.strptime(value, date_format)
29
+ rescue
30
+ puts "Error #{value}, #{index}"
31
+ end
28
32
  end
29
33
  values[index] = date
30
34
  end
data/lib/sycsvpro/dsl.rb CHANGED
@@ -28,11 +28,20 @@ module Dsl
28
28
  end
29
29
 
30
30
  # Remove leading and trailing " and spaces as well as reducing more than 2 spaces between words
31
- # from csv values like "a";ba g;c;"d";e to a;b ag;c;d;e
31
+ # from csv values. Replac ; with , from values as ; is used as value separator
32
32
  def unstring(line)
33
+ line = str2utf8(line)
34
+ line.scan(/(?<=^"|;")[^"]+(?=;)+[^"]*|;+[^"](?=";|"$)/).each do |value|
35
+ line = line.gsub(value, value.gsub(';', ','))
36
+ end
33
37
  line.gsub(/(?<=^|;)\s*"?\s*|\s*"?\s*(?=;|$)/, "").gsub(/\s{2,}/, " ") unless line.nil?
34
38
  end
35
39
 
40
+ # Remove non-UTF chars from string
41
+ def str2utf8(str)
42
+ str.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
43
+ end
44
+
36
45
  private
37
46
 
38
47
  # Assigns values to keys that are used in rows and yielded to the block
@@ -20,14 +20,17 @@ module Sycsvpro
20
20
  attr_reader :col_type_filter
21
21
  # sorted rows
22
22
  attr_reader :sorted_rows
23
+ # file doesn't contain a header
24
+ attr_reader :headerless
23
25
  # sort order descending or ascending
24
26
  attr_reader :desc
25
27
 
26
28
  # Creates a Sorter and takes as options infile, outfile, rows, cols including types and a
27
- # date format for the date columns to sort (optional)
29
+ # date format for the date columns to sort (optional).
28
30
  def initialize(options={})
29
31
  @infile = options[:infile]
30
32
  @outfile = options[:outfile]
33
+ @headerless = options[:headerless] || false
31
34
  @desc = options[:desc] || false
32
35
  @row_filter = RowFilter.new(options[:rows])
33
36
  @col_type_filter = ColumnTypeFilter.new(options[:cols], df: options[:df])
@@ -38,6 +41,11 @@ module Sycsvpro
38
41
  def execute
39
42
  rows = File.readlines(infile)
40
43
 
44
+ unless headerless
45
+ header = ""
46
+ header = rows.shift while header.chomp.strip.empty?
47
+ end
48
+
41
49
  rows.each_with_index do |line, index|
42
50
  filtered = col_type_filter.process(row_filter.process(line, row: index))
43
51
  next if filtered.nil?
@@ -45,6 +53,10 @@ module Sycsvpro
45
53
  end
46
54
 
47
55
  File.open(outfile, 'w') do |out|
56
+ unless headerless
57
+ out.puts header
58
+ end
59
+
48
60
  if desc
49
61
  sorted_rows.compact.sort.reverse.each do |row|
50
62
  out.puts unstring(rows[row.last])
@@ -1,5 +1,5 @@
1
1
  # Operating csv files
2
2
  module Sycsvpro
3
3
  # Version number of sycsvpro
4
- VERSION = '0.0.8'
4
+ VERSION = '0.0.9'
5
5
  end
@@ -7,6 +7,7 @@ module Sycsvpro
7
7
  before do
8
8
  @in_file = File.join(File.dirname(__FILE__), "files/in.csv")
9
9
  @in_2_file = File.join(File.dirname(__FILE__), "files/in2.csv")
10
+ @in_3_file = File.join(File.dirname(__FILE__), "files/in3.csv")
10
11
  @out_file = File.join(File.dirname(__FILE__), "files/out.csv")
11
12
  end
12
13
 
@@ -15,7 +16,8 @@ module Sycsvpro
15
16
  cols = "s:0"
16
17
  df = "%d.%m.%Y"
17
18
 
18
- sorter = Sorter.new(infile: @in_file, outfile: @out_file, rows: rows, cols: cols, df: df)
19
+ sorter = Sorter.new(infile: @in_file, outfile: @out_file, rows: rows, cols: cols, df: df,
20
+ headerless: true)
19
21
 
20
22
  sorter.execute
21
23
 
@@ -37,7 +39,8 @@ module Sycsvpro
37
39
  cols = "n:1,s:0"
38
40
  df = "%d.%m.%Y"
39
41
 
40
- sorter = Sorter.new(infile: @in_file, outfile: @out_file, rows: rows, cols: cols, df: df)
42
+ sorter = Sorter.new(infile: @in_file, outfile: @out_file, rows: rows, cols: cols, df: df,
43
+ headerless: true)
41
44
 
42
45
  sorter.execute
43
46
 
@@ -59,7 +62,8 @@ module Sycsvpro
59
62
  cols = "s:3-5,s:0"
60
63
  df = "%d.%m.%Y"
61
64
 
62
- sorter = Sorter.new(infile: @in_file, outfile: @out_file, rows: rows, cols: cols, df: df)
65
+ sorter = Sorter.new(infile: @in_file, outfile: @out_file, rows: rows, cols: cols, df:
66
+ df, headerless: true)
63
67
 
64
68
  sorter.execute
65
69
 
@@ -82,7 +86,8 @@ module Sycsvpro
82
86
  cols = "d:2,s:0"
83
87
  df = "%d.%m.%Y"
84
88
 
85
- sorter = Sorter.new(infile: @in_file, outfile: @out_file, rows: rows, cols: cols, df: df)
89
+ sorter = Sorter.new(infile: @in_file, outfile: @out_file, rows: rows, cols: cols, df: df,
90
+ headerless: true)
86
91
 
87
92
  sorter.execute
88
93
 
@@ -105,7 +110,7 @@ module Sycsvpro
105
110
  df = "%d.%m.%Y"
106
111
 
107
112
  sorter = Sorter.new(infile: @in_file, outfile: @out_file, rows: rows, cols: cols, df: df,
108
- desc: true)
113
+ desc: true, headerless: true)
109
114
 
110
115
  sorter.execute
111
116
 
@@ -128,7 +133,7 @@ module Sycsvpro
128
133
  df = "%d.%m.%Y"
129
134
 
130
135
  sorter = Sorter.new(infile: @in_2_file, outfile: @out_file, rows: rows, cols: cols, df: df,
131
- desc: false)
136
+ desc: false, headerless: true)
132
137
 
133
138
  sorter.execute
134
139
 
@@ -147,7 +152,7 @@ module Sycsvpro
147
152
  df = "%d.%m.%Y"
148
153
 
149
154
  sorter = Sorter.new(infile: @in_2_file, outfile: @out_file, rows: rows, cols: cols, df: df,
150
- desc: true)
155
+ desc: true, headerless: true)
151
156
 
152
157
  sorter.execute
153
158
 
@@ -166,7 +171,7 @@ module Sycsvpro
166
171
  df = "%d.%m.%Y"
167
172
 
168
173
  sorter = Sorter.new(infile: @in_2_file, outfile: @out_file, rows: rows, cols: cols, df: df,
169
- desc: false)
174
+ desc: false, headerless: true)
170
175
 
171
176
  sorter.execute
172
177
 
@@ -179,6 +184,29 @@ module Sycsvpro
179
184
  end
180
185
  end
181
186
 
187
+ it "should sort strings with values containing value separators" do
188
+ rows = "0-6"
189
+ cols = "s:1,s:4,s:5"
190
+ df = "%d.%m.%Y"
191
+
192
+ sorter = Sorter.new(infile: @in_3_file, outfile: @out_file, rows: rows, cols: cols, df: df,
193
+ desc: false, headerless: true)
194
+
195
+ sorter.execute
196
+
197
+ result = [ "Fink;1234;20.12.2015;f1;con123;dri222",
198
+ "fink;1234;;f3;con332;dri321,dri323",
199
+ "Fink;1234;30.12.2016;f2;con333;dri321",
200
+ "Rank;3232;1.5.2013;r1;con332;dri321",
201
+ "Haas;3322;1.10.2011;h1;con332;dri111",
202
+ "Gent;4323,4434;1.3.2014;g1;con123;dri111",
203
+ "Klig;4432;;k1;con332,con331;dri222" ]
204
+
205
+ File.open(@out_file).each_with_index do |line, index|
206
+ line.chomp.should eq result[index]
207
+ end
208
+ end
209
+
182
210
  end
183
211
 
184
212
  end
data/sycsvpro.rdoc CHANGED
@@ -7,12 +7,13 @@ SYNOPSIS
7
7
  sycsvpro [global options] command [command options] [arguments...]
8
8
 
9
9
  VERSION
10
- 0.0.8
10
+ 0.0.9
11
11
 
12
12
  GLOBAL OPTIONS
13
13
  -f, --file=FILE - CSV file to operate on (default: none)
14
14
  --help - Show this message
15
15
  -o, --out=OUT_FILE - CSV file to write the result to (default: none)
16
+ -s, --[no-]silent - Silent progress doesn't show progress indicator
16
17
  --version - Display the program version
17
18
 
18
19
  COMMANDS
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sycsvpro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Sugar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-26 00:00:00.000000000 Z
11
+ date: 2014-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake