sycsvpro 0.0.9 → 0.1.0

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.
@@ -5,17 +5,18 @@ module Sycsvpro
5
5
  describe Counter do
6
6
 
7
7
  before do
8
- @in_file = File.join(File.dirname(__FILE__), "files/in.csv")
9
- @out_file = File.join(File.dirname(__FILE__), "files/out.csv")
8
+ @in_file = File.join(File.dirname(__FILE__), "files/in.csv")
9
+ @in_ibase_file = File.join(File.dirname(__FILE__), "files/ibase.csv")
10
+ @out_file = File.join(File.dirname(__FILE__), "files/out.csv")
10
11
  end
11
12
 
12
13
  it "should count columns" do
13
14
  counter = Counter.new(infile: @in_file, outfile: @out_file, rows: "1-10", cols: "4,5",
14
- key: "0")
15
+ key: "0:customer")
15
16
 
16
17
  counter.execute
17
18
 
18
- result = [ "key;con123;con332;con333;dri111;dri222;dri321",
19
+ result = [ "customer;con123;con332;con333;dri111;dri222;dri321",
19
20
  "Fink;1;0;1;0;1;1",
20
21
  "Haas;0;1;0;1;0;0",
21
22
  "Gent;1;0;0;1;0;0",
@@ -29,14 +30,14 @@ module Sycsvpro
29
30
 
30
31
  end
31
32
 
32
- it "should count date coloms" do
33
+ it "should count date columns" do
33
34
  counter = Counter.new(infile: @in_file, outfile: @out_file, rows: "1-10",
34
- cols: "2:<1.1.2013,2:1.1.2013-31.12.2014,2:>31.12.2014", key: "0",
35
- df: "%d.%m.%Y")
35
+ cols: "2:<1.1.2013,2:1.1.2013-31.12.2014,2:>31.12.2014",
36
+ key: "0:customer", df: "%d.%m.%Y")
36
37
 
37
38
  counter.execute
38
39
 
39
- result = [ "key;1.1.2013-31.12.2014;<1.1.2013;>31.12.2014",
40
+ result = [ "customer;1.1.2013-31.12.2014;<1.1.2013;>31.12.2014",
40
41
  "Fink;0;0;2",
41
42
  "Haas;0;1;0",
42
43
  "Gent;1;0;0",
@@ -50,12 +51,12 @@ module Sycsvpro
50
51
 
51
52
  it "should add a sum row" do
52
53
  counter = Counter.new(infile: @in_file, outfile: @out_file, rows: "1-10",
53
- cols: "2:<1.1.2013,2:1.1.2013-31.12.2014,2:>31.12.2014", key: "0",
54
- df: "%d.%m.%Y", sum: "Total:1")
54
+ cols: "2:<1.1.2013,2:1.1.2013-31.12.2014,2:>31.12.2014",
55
+ key: "0:customer", df: "%d.%m.%Y", sum: "Total:1")
55
56
 
56
57
  counter.execute
57
58
 
58
- result = [ "key;1.1.2013-31.12.2014;<1.1.2013;>31.12.2014",
59
+ result = [ "customer;1.1.2013-31.12.2014;<1.1.2013;>31.12.2014",
59
60
  "Total;2;1;2",
60
61
  "Fink;0;0;2",
61
62
  "Haas;0;1;0",
@@ -68,6 +69,71 @@ module Sycsvpro
68
69
 
69
70
  end
70
71
 
72
+ it "should add a sum row and column" do
73
+ counter = Counter.new(infile: @in_file, outfile: @out_file, rows: "1-10",
74
+ cols: "2:<1.1.2013,2:1.1.2013-31.12.2014,2:>31.12.2014",
75
+ key: "0:customer", df: "%d.%m.%Y", sum: "Total:1,Sumsup")
76
+ counter.execute
77
+
78
+ result = [ "customer;1.1.2013-31.12.2014;<1.1.2013;>31.12.2014;Sumsup",
79
+ "Total;2;1;2;5",
80
+ "Fink;0;0;2;2",
81
+ "Haas;0;1;0;1",
82
+ "Gent;1;0;0;1",
83
+ "Rank;1;0;0;1" ]
84
+
85
+ File.open(@out_file).each_with_index do |line, index|
86
+ line.chomp.should eq result[index]
87
+ end
88
+
89
+ end
90
+
91
+ it "should count column values based on number comparison" do
92
+ counter = Counter.new(infile: @in_ibase_file, outfile: @out_file, rows: "1-10",
93
+ cols: "1:<10,1:10-50,1:>50", key: "0:customer", sum: "Total:1,Sumsup")
94
+ counter.execute
95
+
96
+ result = [ "customer;10-50;<10;>50;Sumsup",
97
+ "Total;3;4;2;9",
98
+ "Fink;0;1;0;1",
99
+ "Haas;1;0;0;1",
100
+ "Rank;0;0;1;1",
101
+ "Klick;1;0;0;1",
102
+ "Black;0;1;0;1",
103
+ "White;0;0;1;1",
104
+ "Tong;0;1;0;1",
105
+ "Rinda;0;1;0;1",
106
+ "Pings;1;0;0;1" ]
107
+
108
+ File.open(@out_file).each_with_index do |line, index|
109
+ line.chomp.should eq result[index]
110
+ end
111
+ end
112
+
113
+ it "should use multiple key columns" do
114
+ counter = Counter.new(infile: @in_ibase_file, outfile: @out_file, rows: "1-10",
115
+ cols: "1:<10,1:10-50,1:>50", key: "0:customer,1:machines",
116
+ sum: "Total:1,Sumsup")
117
+ counter.execute
118
+
119
+ result = [ "customer;machines;10-50;<10;>50;Sumsup",
120
+ "Total;;3;4;2;9",
121
+ "Fink;9;0;1;0;1",
122
+ "Haas;34;1;0;0;1",
123
+ "Rank;60;0;0;1;1",
124
+ "Klick;25;1;0;0;1",
125
+ "Black;2;0;1;0;1",
126
+ "White;88;0;0;1;1",
127
+ "Tong;3;0;1;0;1",
128
+ "Rinda;8;0;1;0;1",
129
+ "Pings;15;1;0;0;1" ]
130
+
131
+ File.open(@out_file).each_with_index do |line, index|
132
+ line.chomp.should eq result[index]
133
+ end
134
+
135
+ end
136
+
71
137
  end
72
138
 
73
139
  end
data/sycsvpro.rdoc CHANGED
@@ -7,7 +7,7 @@ SYNOPSIS
7
7
  sycsvpro [global options] command [command options] [arguments...]
8
8
 
9
9
  VERSION
10
- 0.0.9
10
+ 0.1.0
11
11
 
12
12
  GLOBAL OPTIONS
13
13
  -f, --file=FILE - CSV file to operate on (default: none)
@@ -17,18 +17,19 @@ GLOBAL OPTIONS
17
17
  --version - Display the program version
18
18
 
19
19
  COMMANDS
20
- allocate - Allocate specified columns from the file to a key value
21
- analyze - Analyze the CSV file regarding columns, rows and content
22
- calc - Process math operations on columns
23
- collect - Collect values of specified rows and columns from the file and group them in
24
- categories
25
- count - Counts the occurences of column values. Uses column values as headings with count as
26
- values. Columns with a condition will be added as new columns and the condition will
27
- be set as column name. Optionally adds a sum row
28
- execute - Executes the code provided in a file
29
- extract - Extract specified rows and columns from the file
30
- help - Shows a list of commands or help for one command
31
- insert - Inserts rows from a file to a csv-file
32
- list - List scripts in the scripts directory with optionally listing methods
33
- map - Map values in columns to new values
34
- sort - Sort columns based on column values
20
+ aggregate - Aggregates the occurences of row values. Optionally adds a sum row
21
+ allocate - Allocate specified columns from the file to a key value
22
+ analyze - Analyze the CSV file regarding columns, rows and content
23
+ calc - Process math operations on columns. Optionally adds a sum row
24
+ collect - Collect values of specified rows and columns from the file and group them in
25
+ categories
26
+ count - Counts the occurences of column values. Uses column values as headings with count as
27
+ values. Columns with a condition will be added as new columns and the condition will
28
+ be set as column name. Optionally adds a sum row
29
+ execute - Executes the code provided in a file
30
+ extract - Extract specified rows and columns from the file
31
+ help - Shows a list of commands or help for one command
32
+ insert - Inserts rows from a file to a csv-file
33
+ list - List scripts in the scripts directory with optionally listing methods
34
+ map - Map values in columns to new values
35
+ sort - Sort columns based on column values
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.9
4
+ version: 0.1.0
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-03-02 00:00:00.000000000 Z
11
+ date: 2014-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -105,6 +105,7 @@ files:
105
105
  - html/Object.html
106
106
  - html/README_rdoc.html
107
107
  - html/Sycsvpro.html
108
+ - html/Sycsvpro/Aggregator.html
108
109
  - html/Sycsvpro/Allocator.html
109
110
  - html/Sycsvpro/Analyzer.html
110
111
  - html/Sycsvpro/Calculator.html
@@ -165,6 +166,7 @@ files:
165
166
  - html/rdoc.css
166
167
  - html/table_of_contents.html
167
168
  - lib/sycsvpro.rb
169
+ - lib/sycsvpro/aggregator.rb
168
170
  - lib/sycsvpro/allocator.rb
169
171
  - lib/sycsvpro/analyzer.rb
170
172
  - lib/sycsvpro/calculator.rb
@@ -184,6 +186,7 @@ files:
184
186
  - lib/sycsvpro/script_list.rb
185
187
  - lib/sycsvpro/sorter.rb
186
188
  - lib/sycsvpro/version.rb
189
+ - spec/sycsvpro/aggregator_spec.rb
187
190
  - spec/sycsvpro/allocator_spec.rb
188
191
  - spec/sycsvpro/analyze_spec.rb
189
192
  - spec/sycsvpro/calculator_spec.rb