csvutils 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c639c6a13e149e81b5255262884abd02fae3c22e
4
- data.tar.gz: 73bec69652d262ebf616c00e8351f8788b0d022a
3
+ metadata.gz: 0be624b7103c77a6542c61522d097a807e207204
4
+ data.tar.gz: 4d6dffcadc2d6906e59eb009085a4b0cf822b81d
5
5
  SHA512:
6
- metadata.gz: 45d8ba36d58577f3362cea9ead2ff9b952992f5038cb453dad6d666948a498269b60ef2c7d15b1c260b291a69c047ab3616ba62d93c92ac6af61cd5e8ae703fc
7
- data.tar.gz: 56ebd4f88a54411e97312a832de6d2d830e1af15e287923535dd51edd4ac11c09ff525a7a27363d9c4255defbae7dc6040f6bb2202439fc06d4bf15adfe01b54
6
+ metadata.gz: 839586401ebf58210d448cfe42f1d3959abbc640f93540e7127dad6fd04666c6cd3f31f07b4cf659000c2e5deda0db32fdbdf2d59d55beb87533ad24f275e193
7
+ data.tar.gz: 69219118ab9871d44797078da35ef5c060b50399334ea00c219471658ce07045f55ab76213ab6743e358e04e1f0be2c4fcf3036274665bc870ee4067530c9cb5
data/HISTORY.md CHANGED
@@ -1,3 +1,3 @@
1
- ### 0.0.1 / 2018-08-04
2
-
3
- * Everything is new. First release.
1
+ ### 0.0.1 / 2018-08-04
2
+
3
+ * Everything is new. First release.
@@ -0,0 +1,116 @@
1
+ CC0 1.0 Universal
2
+
3
+ Statement of Purpose
4
+
5
+ The laws of most jurisdictions throughout the world automatically confer
6
+ exclusive Copyright and Related Rights (defined below) upon the creator and
7
+ subsequent owner(s) (each and all, an "owner") of an original work of
8
+ authorship and/or a database (each, a "Work").
9
+
10
+ Certain owners wish to permanently relinquish those rights to a Work for the
11
+ purpose of contributing to a commons of creative, cultural and scientific
12
+ works ("Commons") that the public can reliably and without fear of later
13
+ claims of infringement build upon, modify, incorporate in other works, reuse
14
+ and redistribute as freely as possible in any form whatsoever and for any
15
+ purposes, including without limitation commercial purposes. These owners may
16
+ contribute to the Commons to promote the ideal of a free culture and the
17
+ further production of creative, cultural and scientific works, or to gain
18
+ reputation or greater distribution for their Work in part through the use and
19
+ efforts of others.
20
+
21
+ For these and/or other purposes and motivations, and without any expectation
22
+ of additional consideration or compensation, the person associating CC0 with a
23
+ Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
24
+ and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
25
+ and publicly distribute the Work under its terms, with knowledge of his or her
26
+ Copyright and Related Rights in the Work and the meaning and intended legal
27
+ effect of CC0 on those rights.
28
+
29
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
30
+ protected by copyright and related or neighboring rights ("Copyright and
31
+ Related Rights"). Copyright and Related Rights include, but are not limited
32
+ to, the following:
33
+
34
+ i. the right to reproduce, adapt, distribute, perform, display, communicate,
35
+ and translate a Work;
36
+
37
+ ii. moral rights retained by the original author(s) and/or performer(s);
38
+
39
+ iii. publicity and privacy rights pertaining to a person's image or likeness
40
+ depicted in a Work;
41
+
42
+ iv. rights protecting against unfair competition in regards to a Work,
43
+ subject to the limitations in paragraph 4(a), below;
44
+
45
+ v. rights protecting the extraction, dissemination, use and reuse of data in
46
+ a Work;
47
+
48
+ vi. database rights (such as those arising under Directive 96/9/EC of the
49
+ European Parliament and of the Council of 11 March 1996 on the legal
50
+ protection of databases, and under any national implementation thereof,
51
+ including any amended or successor version of such directive); and
52
+
53
+ vii. other similar, equivalent or corresponding rights throughout the world
54
+ based on applicable law or treaty, and any national implementations thereof.
55
+
56
+ 2. Waiver. To the greatest extent permitted by, but not in contravention of,
57
+ applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
58
+ unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
59
+ and Related Rights and associated claims and causes of action, whether now
60
+ known or unknown (including existing as well as future claims and causes of
61
+ action), in the Work (i) in all territories worldwide, (ii) for the maximum
62
+ duration provided by applicable law or treaty (including future time
63
+ extensions), (iii) in any current or future medium and for any number of
64
+ copies, and (iv) for any purpose whatsoever, including without limitation
65
+ commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
66
+ the Waiver for the benefit of each member of the public at large and to the
67
+ detriment of Affirmer's heirs and successors, fully intending that such Waiver
68
+ shall not be subject to revocation, rescission, cancellation, termination, or
69
+ any other legal or equitable action to disrupt the quiet enjoyment of the Work
70
+ by the public as contemplated by Affirmer's express Statement of Purpose.
71
+
72
+ 3. Public License Fallback. Should any part of the Waiver for any reason be
73
+ judged legally invalid or ineffective under applicable law, then the Waiver
74
+ shall be preserved to the maximum extent permitted taking into account
75
+ Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
76
+ is so judged Affirmer hereby grants to each affected person a royalty-free,
77
+ non transferable, non sublicensable, non exclusive, irrevocable and
78
+ unconditional license to exercise Affirmer's Copyright and Related Rights in
79
+ the Work (i) in all territories worldwide, (ii) for the maximum duration
80
+ provided by applicable law or treaty (including future time extensions), (iii)
81
+ in any current or future medium and for any number of copies, and (iv) for any
82
+ purpose whatsoever, including without limitation commercial, advertising or
83
+ promotional purposes (the "License"). The License shall be deemed effective as
84
+ of the date CC0 was applied by Affirmer to the Work. Should any part of the
85
+ License for any reason be judged legally invalid or ineffective under
86
+ applicable law, such partial invalidity or ineffectiveness shall not
87
+ invalidate the remainder of the License, and in such case Affirmer hereby
88
+ affirms that he or she will not (i) exercise any of his or her remaining
89
+ Copyright and Related Rights in the Work or (ii) assert any associated claims
90
+ and causes of action with respect to the Work, in either case contrary to
91
+ Affirmer's express Statement of Purpose.
92
+
93
+ 4. Limitations and Disclaimers.
94
+
95
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
96
+ surrendered, licensed or otherwise affected by this document.
97
+
98
+ b. Affirmer offers the Work as-is and makes no representations or warranties
99
+ of any kind concerning the Work, express, implied, statutory or otherwise,
100
+ including without limitation warranties of title, merchantability, fitness
101
+ for a particular purpose, non infringement, or the absence of latent or
102
+ other defects, accuracy, or the present or absence of errors, whether or not
103
+ discoverable, all to the greatest extent permissible under applicable law.
104
+
105
+ c. Affirmer disclaims responsibility for clearing rights of other persons
106
+ that may apply to the Work or any use thereof, including without limitation
107
+ any person's Copyright and Related Rights in the Work. Further, Affirmer
108
+ disclaims responsibility for obtaining any necessary consents, permissions
109
+ or other rights required for any use of the Work.
110
+
111
+ d. Affirmer understands and acknowledges that Creative Commons is not a
112
+ party to this document and has no duty or obligation with respect to this
113
+ CC0 or use of the Work.
114
+
115
+ For more information, please see
116
+ <http://creativecommons.org/publicdomain/zero/1.0/>
@@ -1,4 +1,5 @@
1
1
  HISTORY.md
2
+ LICENSE.md
2
3
  Manifest.txt
3
4
  README.md
4
5
  Rakefile
@@ -7,6 +8,9 @@ bin/csvhead
7
8
  bin/csvheader
8
9
  bin/csvsplit
9
10
  bin/csvstat
11
+ datasets/at-austria/AUT.csv
12
+ datasets/de-deutschland/bundesliga.csv
13
+ datasets/eng-england/2017-18/E0.csv
10
14
  lib/csvutils.rb
11
15
  lib/csvutils/commands/cut.rb
12
16
  lib/csvutils/commands/head.rb
@@ -21,10 +25,10 @@ lib/csvutils/stat.rb
21
25
  lib/csvutils/test.rb
22
26
  lib/csvutils/utils.rb
23
27
  lib/csvutils/version.rb
24
- test/data/at-austria/AUT.csv
25
- test/data/de-deutschland/bundesliga.csv
26
- test/data/eng-england/2017-18/E0.csv
27
28
  test/helper.rb
28
- test/test_headers.rb
29
+ test/test_cut.rb
30
+ test/test_head.rb
31
+ test/test_header.rb
29
32
  test/test_misc.rb
33
+ test/test_split.rb
30
34
  test/test_version.rb
data/README.md CHANGED
@@ -1,286 +1,302 @@
1
- # csvutils - tools 'n' scripts for working with comma-separated values (csv) datafiles - the world's most popular tabular date interchange format in text
2
-
3
-
4
- * home :: [github.com/csv11/csvutils](https://github.com/csv11/csvutils)
5
- * bugs :: [github.com/csv11/csvutils/issues](https://github.com/csv11/csvutils/issues)
6
- * gem :: [rubygems.org/gems/csvutils](https://rubygems.org/gems/csvutils)
7
- * rdoc :: [rubydoc.info/gems/csvutils](http://rubydoc.info/gems/csvutils)
8
- * forum :: [wwwmake](http://groups.google.com/group/wwwmake)
9
-
10
-
11
-
12
- ## Usage
13
-
14
- ### Command Line Tools
15
-
16
- `csvhead` • `csvheader` • `csvstat` • `csvsplit` • `csvcut`
17
-
18
-
19
- Try:
20
-
21
- ```
22
- $ csvhead -h # or
23
- $ csvhead --help
24
- ```
25
-
26
- resulting in:
27
-
28
- ```
29
- Usage: csvhead [OPTS] datafile ...
30
- -n, --num=NUM Number of rows
31
- -h, --help Prints this help
32
- ```
33
-
34
- and so on. Now try with `csvheader -h`, `csvstat -h`, `csvsplit -h`,
35
- `csvcut -h` and so on.
36
-
37
-
38
-
39
- #### Working with Comma-Separated Values (CSV) Datafile Examples
40
-
41
- Let's use a sample datafile e.g. `E0.csv` from the [football.csv project]() with
42
- matches from the English Premier League. Try
43
-
44
- ```
45
- $ csvhead E0.csv
46
- ```
47
- to pretty print (pp) the first four row (use the `-n` option for more or less rows).
48
- Resulting in:
49
-
50
- ```
51
- == E0.csv (.) ==
52
-
53
- #<CSV::Row "Date":nil "HomeTeam":"Arsenal" "AwayTeam":"Leicester" "FTHG":"4" "FTAG":"3" "HTHG":"2" "HTAG":"2">
54
- #<CSV::Row "Date":nil "HomeTeam":"Brighton" "AwayTeam":"Man City" "FTHG":"0" "FTAG":"2" "HTHG":"?" "HTAG":"?">
55
- #<CSV::Row "Date":"12/08/17" "HomeTeam":"Chelsea" "AwayTeam":"Burnley" "FTHG":"2" "FTAG":"3" "HTHG":"?" "HTAG":"?">
56
- #<CSV::Row "Date":"-" "HomeTeam":"Crystal Palace" "AwayTeam":"Huddersfield" "FTHG":"0" "FTAG":"3" "HTHG":"0" "HTAG":"2">
57
-
58
- 4 rows
59
- ```
60
-
61
- Next try
62
-
63
- ```
64
- $ csvheader E0.csv
65
- ```
66
-
67
- to print all header columns (the first row). Resulting in:
68
-
69
- ```
70
- == E0.csv (.) ==
71
-
72
- 7 columns:
73
- 1: Date
74
- 2: HomeTeam
75
- 3: AwayTeam
76
- 4: FTHG
77
- 5: FTAG
78
- 6: HTHG
79
- 7: HTAG
80
- ```
81
-
82
- Next try:
83
-
84
- ```
85
- $ csvstat -c HomeTeam,AwayTeam E0.csv
86
- ```
87
-
88
- to show all unique values for the columns `HomeTeam` and `AwayTeam`.
89
- Resulting in:
90
-
91
- ```
92
- == E0.csv (.) ==
93
-
94
- ... 380 rows
95
-
96
- 7 columns:
97
- 1: Date
98
- 2: HomeTeam
99
- 3: AwayTeam
100
- 4: FTHG
101
- 5: FTAG
102
- 6: HTHG
103
- 7: HTAG
104
-
105
- column >HomeTeam< 21 unique values:
106
- 1 x <nil>
107
- 19 x Arsenal
108
- 18 x Bournemouth
109
- 19 x Brighton
110
- 19 x Burnley
111
- 19 x Chelsea
112
- 19 x Crystal Palace
113
- 19 x Everton
114
- 19 x Huddersfield
115
- 19 x Leicester
116
- 19 x Liverpool
117
- 19 x Man City
118
- 19 x Man United
119
- 19 x Newcastle
120
- 19 x Southampton
121
- 19 x Stoke
122
- 19 x Swansea
123
- 19 x Tottenham
124
- 19 x Watford
125
- 19 x West Brom
126
- 19 x West Ham
127
- column >AwayTeam< 21 unique values:
128
- 1 x ?
129
- 19 x Arsenal
130
- 19 x Bournemouth
131
- 19 x Brighton
132
- 19 x Burnley
133
- 19 x Chelsea
134
- 19 x Crystal Palace
135
- 19 x Everton
136
- 19 x Huddersfield
137
- 19 x Leicester
138
- 19 x Liverpool
139
- 19 x Man City
140
- 19 x Man United
141
- 19 x Newcastle
142
- 19 x Southampton
143
- 19 x Stoke
144
- 19 x Swansea
145
- 19 x Tottenham
146
- 18 x Watford
147
- 19 x West Brom
148
- 19 x West Ham
149
- ```
150
-
151
-
152
- #### Split & Cut - Split One Datafile into Many or Cut / Reorder Columns
153
-
154
- Let's use another sample datafile e.g. `AUT.csv` that holds many seasons
155
- from the Austrian (AUT) Bundesliga. First lets see how many seasons:
156
-
157
- ```
158
- $ csvstat -c Season AUT.csv
159
- ```
160
-
161
- Resulting in:
162
-
163
- ```
164
- == AUT.csv (.) ==
165
-
166
- ... 362 rows
167
-
168
- 7 columns:
169
- 1: Season
170
- 2: Date
171
- 3: Time
172
- 4: Home
173
- 5: Away
174
- 6: HG
175
- 7: AG
176
-
177
- column >Season< 2 unique values:
178
- 180 x 2016/2017
179
- 182 x 2017/2018
180
- ```
181
-
182
- Now let's split the `AUT.csv` datafile by the `Season` column
183
- resulting in two new datafiles named `AUT_2016-2017.csv`
184
- and `ÀUT_2017-2018.csv`. Try:
185
-
186
- ```
187
- $ csvsplit -c Season AUT.csv
188
- ```
189
-
190
- Resulting in:
191
-
192
- ```
193
- new chunk: ["2016/2017"]
194
- saving >AUT_2016-2017.csv<...
195
- new chunk: ["2017/2018"]
196
- saving >AUT_2017-2018.csv<...
197
- ```
198
-
199
- Let's cut out (remove) the `Season` and `Time` column from the new `AUT_2016-2017.csv`
200
- datafile. Try:
201
-
202
- ```
203
- $ csvcut -c Date,Home,Away,HG,AG AUT_2016-2017.csv
204
- ```
205
-
206
- Double check the overwritten cleaned-up datafile:
207
-
208
- ```
209
- $ csvhead AUT_2016-2017.csv
210
- ```
211
-
212
- resulting in:
213
-
214
- ```
215
-
216
- ```
217
-
218
- And so on and so forth.
219
-
220
-
221
-
222
-
223
- ### Code, Code, Code - Script Your Data Work Flow with Ruby
224
-
225
- You can use all tools in your script using the `CsvUtils`
226
- class methods:
227
-
228
- | Shell | Ruby |
229
- |-------------|-----------------------------------|
230
- | `csvhead` | `CsvUtils.head( path, n: 4 )` |
231
- | `csvheader` | `CsvUtils.header( path )` |
232
- | `csvstat` | `CsvUtils.stat( path, *columns )` |
233
- | `csvsplit` | `CsvUtils.split( path, *columns )` |
234
- | `csvcut` | `CsvUtils.cut( path, *columns, output: path)` |
235
-
236
-
237
-
238
- Let's retry the sample above in a script:
239
-
240
-
241
- ``` ruby
242
- require 'csvutils'
243
-
244
-
245
- CsvUtils.head( 'E0.csv' )
246
- # same as
247
- # $ csvhead E0.csv
248
-
249
- CsvUtils.header( 'E0.csv' )
250
- # => see above :-)
251
-
252
- CsvUtils.stat( 'E0.csv', 'HomeTeam', 'AwayTeam' )
253
- # same as:
254
- # $ csvstat -c HomeTeam,AwayTeam E0.csv
255
-
256
-
257
- CsvUtils.stat( 'AUT.csv', 'Season' )
258
- # => same as
259
- # $ csvstat -c Season AUT.csv
260
-
261
-
262
- CsvUtils.split( 'AUT.csv', 'Season' )
263
- # => see above :-)
264
-
265
- CsvUtils.cut( 'AUT_2016-2017.csv', 'AUT_2016-2017.csv', 'Date', 'Home', 'Away', 'HG', 'AG' )
266
- # => see above :-)
267
-
268
-
269
- ```
270
-
271
-
272
- That's it.
273
-
274
-
275
- ## License
276
-
277
-
278
- ![](https://publicdomainworks.github.io/buttons/zero88x31.png)
279
-
280
- The `csvutils` scripts are dedicated to the public domain.
281
- Use it as you please with no restrictions whatsoever.
282
-
283
- ## Questions? Comments?
284
-
285
- Send them along to the [wwwmake forum](http://groups.google.com/group/wwwmake).
286
- Thanks!
1
+ # csvutils - tools 'n' scripts for working with comma-separated values (csv) datafiles - the world's most popular tabular data interchange format in text
2
+
3
+
4
+ * home :: [github.com/csvreader/csvutils](https://github.com/csvreader/csvutils)
5
+ * bugs :: [github.com/csvreader/csvutils/issues](https://github.com/csvreader/csvutils/issues)
6
+ * gem :: [rubygems.org/gems/csvutils](https://rubygems.org/gems/csvutils)
7
+ * rdoc :: [rubydoc.info/gems/csvutils](http://rubydoc.info/gems/csvutils)
8
+ * forum :: [wwwmake](http://groups.google.com/group/wwwmake)
9
+
10
+
11
+
12
+ ## Usage
13
+
14
+ ### Command Line Tools
15
+
16
+ `csvhead` • `csvheader` • `csvstat` • `csvsplit` • `csvcut`
17
+
18
+
19
+ Try the help option `-h/--help` with the command line tools. Example:
20
+
21
+ ```
22
+ $ csvhead -h # or
23
+ $ csvhead --help
24
+ ```
25
+
26
+ resulting in:
27
+
28
+ ```
29
+ Usage: csvhead [OPTS] datafile ...
30
+ -n, --num=NUM Number of rows
31
+ -h, --help Prints this help
32
+ ```
33
+
34
+ Now try it with `csvheader -h`, `csvstat -h`, `csvsplit -h`,
35
+ `csvcut -h` and so on.
36
+
37
+
38
+
39
+ #### Working with Comma-Separated Values (CSV) Datafile Examples
40
+
41
+ Let's use a sample datafile e.g. [`ENG.csv`](getting-started-samples/ENG.csv) from the
42
+ [football.csv project](https://github.com/footballcsv) with
43
+ matches from the English Premier League. Try
44
+
45
+
46
+ ```
47
+ $ csvhead ENG.csv
48
+ ```
49
+ to pretty print (pp) the first four rows (use the `-n/--num` option for more or less rows).
50
+ Resulting in:
51
+
52
+ ```
53
+ == ENG.csv ==
54
+
55
+ <Date:11/08/17, Team1:Arsenal, Team2:Leicester, FT1:4, FT2:3>
56
+ <Date:12/08/17, Team1:Brighton, Team2:Man City, FT1:0, FT2:2>
57
+ <Date:12/08/17, Team1:Chelsea, Team2:Burnley, FT1:2, FT2:3>
58
+ <Date:12/08/17, Team1:Crystal Palace, Team2:Huddersfield, FT1:0, FT2:3>
59
+ 4 rows
60
+ ```
61
+
62
+ Next try
63
+
64
+ ```
65
+ $ csvheader ENG.csv
66
+ ```
67
+
68
+ to print all header columns (the first row). Resulting in:
69
+
70
+ ```
71
+ == ENG.csv ==
72
+
73
+ 5 columns:
74
+ 1: Date
75
+ 2: Team1
76
+ 3: Team2
77
+ 4: FT1
78
+ 5: FT2
79
+ ```
80
+
81
+ Next try:
82
+
83
+ ```
84
+ $ csvstat -c Team1,Team2 ENG.csv
85
+ ```
86
+
87
+ to show all unique values for the columns `Team1` and `Team2`.
88
+ Resulting in:
89
+
90
+ ```
91
+ == ENG.csv ==
92
+
93
+ ... 380 rows
94
+
95
+ 5 columns:
96
+ 1: Date
97
+ 2: Team1
98
+ 3: Team2
99
+ 4: FT1
100
+ 5: FT2
101
+
102
+ column "Team1" - 20 unique values:
103
+ 19 x Arsenal
104
+ 19 x Bournemouth
105
+ 19 x Brighton
106
+ 19 x Burnley
107
+ 19 x Chelsea
108
+ 19 x Crystal Palace
109
+ 19 x Everton
110
+ 19 x Huddersfield
111
+ 19 x Leicester
112
+ 19 x Liverpool
113
+ 19 x Man City
114
+ 19 x Man United
115
+ 19 x Newcastle
116
+ 19 x Southampton
117
+ 19 x Stoke
118
+ 19 x Swansea
119
+ 19 x Tottenham
120
+ 19 x Watford
121
+ 19 x West Brom
122
+ 19 x West Ham
123
+ column "Team2" - 20 unique values:
124
+ 19 x Arsenal
125
+ 19 x Bournemouth
126
+ 19 x Brighton
127
+ 19 x Burnley
128
+ 19 x Chelsea
129
+ 19 x Crystal Palace
130
+ 19 x Everton
131
+ 19 x Huddersfield
132
+ 19 x Leicester
133
+ 19 x Liverpool
134
+ 19 x Man City
135
+ 19 x Man United
136
+ 19 x Newcastle
137
+ 19 x Southampton
138
+ 19 x Stoke
139
+ 19 x Swansea
140
+ 19 x Tottenham
141
+ 19 x Watford
142
+ 19 x West Brom
143
+ 19 x West Ham
144
+ ```
145
+
146
+
147
+ #### Split & Cut - Split One Datafile into Many or Cut / Reorder Columns
148
+
149
+ Let's use another sample datafile e.g. [`AUT.csv`](getting-started-samples/AUT.csv) that holds many seasons
150
+ from the Austrian (AUT) Bundesliga. First lets see how many seasons:
151
+
152
+ ```
153
+ $ csvstat -c Season AUT.csv
154
+ ```
155
+
156
+ Resulting in:
157
+
158
+ ```
159
+ == AUT.csv ==
160
+
161
+ ... 360 rows
162
+
163
+ 6 columns:
164
+ 1: Season
165
+ 2: Date
166
+ 3: Team1
167
+ 4: Team2
168
+ 5: FT1
169
+ 6: FT2
170
+
171
+ column "Season" - 2 unique values:
172
+ 180 x 2016/2017
173
+ 180 x 2017/2018
174
+ ```
175
+
176
+ Now let's split the `AUT.csv` datafile by the `Season` column
177
+ resulting in two new datafiles named `AUT_2016-2017.csv`
178
+ and `ÀUT_2017-2018.csv`. Try:
179
+
180
+ ```
181
+ $ csvsplit -c Season AUT.csv
182
+ ```
183
+
184
+ Resulting in:
185
+
186
+ ```
187
+ new chunk: ["2016/2017"] - saving "AUT_2016-2017.csv"...
188
+ new chunk: ["2017/2018"] - saving "AUT_2017-2018.csv"...
189
+ ```
190
+
191
+ Let's cut out (remove) the `Season` column from the new `AUT_2016-2017.csv`
192
+ datafile. Try:
193
+
194
+ ```
195
+ $ csvcut -c Date,Team1,Team2,FT1,FT2 AUT_2016-2017.csv
196
+ ```
197
+
198
+ Double check the overwritten in-place cleaned-up datafile:
199
+
200
+ ```
201
+ $ csvhead AUT_2016-2017.csv
202
+ ```
203
+
204
+ resulting in:
205
+
206
+ ```
207
+ == AUT_2016-2017.csv ==
208
+
209
+ <Date:23/07/16, Team1:Rapid Vienna, Team2:Ried, FT1:5, FT2:0>
210
+ <Date:23/07/16, Team1:Altach, Team2:AC Wolfsberger, FT1:1, FT2:0>
211
+ <Date:23/07/16, Team1:Sturm Graz, Team2:Salzburg, FT1:3, FT2:1>
212
+ <Date:24/07/16, Team1:St. Pölten, Team2:Austria Vienna, FT1:1, FT2:2>
213
+ 4 rows
214
+ ```
215
+
216
+ And so on and so forth.
217
+
218
+
219
+
220
+
221
+ ### Code, Code, Code - Script Your Data Work Flow with Ruby
222
+
223
+ You can use all tools in your script using the `CsvUtils`
224
+ class methods:
225
+
226
+ | Shell | Ruby |
227
+ |-------------|-----------------------------------|
228
+ | `csvhead` | [`CsvUtils.head( path, n: 4 )`](lib/csvutils/head.rb) |
229
+ | `csvheader` | [`CsvUtils.header( path )`](lib/csvutils/header.rb) |
230
+ | `csvstat` | [`CsvUtils.stat( path, *columns )`](lib/csvutils/stat.rb) |
231
+ | `csvsplit` | [`CsvUtils.split( path, *columns )`](lib/csvutils/split.rb) |
232
+ | `csvcut` | [`CsvUtils.cut( path, *columns, output: path)`](lib/csvutils/cut.rb) |
233
+
234
+
235
+
236
+ Let's retry the sample above in a script:
237
+
238
+
239
+ ``` ruby
240
+ require 'csvutils'
241
+
242
+
243
+ CsvUtils.head( 'ENG.csv' )
244
+ # same as:
245
+ # $ csvhead ENG.csv
246
+
247
+ CsvUtils.header( 'ENG.csv' )
248
+ # same as:
249
+ # $ csvheader ENG.csv
250
+
251
+ CsvUtils.stat( 'ENG.csv', 'Team1', 'Team2' )
252
+ # same as:
253
+ # $ csvstat -c Team1,Team2 ENG.csv
254
+
255
+
256
+ CsvUtils.stat( 'AUT.csv', 'Season' )
257
+ # same as:
258
+ # $ csvstat -c Season AUT.csv
259
+
260
+ CsvUtils.split( 'AUT.csv', 'Season' )
261
+ # same as:
262
+ # $ csvsplit -c Season AUT.csv
263
+
264
+ CsvUtils.cut( 'AUT_2016-2017.csv', 'Date', 'Team1', 'Team2', 'FT1', 'FT2' )
265
+ # same as:
266
+ # $ csvcut -c Date,Team1,Team2,FT1,FT2 AUT_2016-2017.csv
267
+ ```
268
+
269
+
270
+
271
+ That's it. See the [`/getting-started-samples`](/getting-started-samples)
272
+ folder to
273
+ run the samples on your own computer.
274
+
275
+
276
+
277
+ ## Install
278
+
279
+ Just install the gem:
280
+
281
+ ```
282
+ $ gem install csvutils
283
+ ```
284
+
285
+
286
+
287
+ ## Alternatives
288
+
289
+ See the Libraries & Tools section in the [Awesome CSV](https://github.com/csvspecs/awesome-csv#libraries--tools) page.
290
+
291
+
292
+ ## License
293
+
294
+ ![](https://publicdomainworks.github.io/buttons/zero88x31.png)
295
+
296
+ The `csvutils` scripts are dedicated to the public domain.
297
+ Use it as you please with no restrictions whatsoever.
298
+
299
+ ## Questions? Comments?
300
+
301
+ Send them along to the [wwwmake forum](http://groups.google.com/group/wwwmake).
302
+ Thanks!