csvutils 0.1.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 435468b42345511466981b9f470e39e1dc78bfea
4
- data.tar.gz: f2b4c42ec30da76fe929942d6d0706420dd63f63
3
+ metadata.gz: c0d329f76a01f6d844f43a3e7913922f5a83635a
4
+ data.tar.gz: '0889bf3f11b092bd5f845d4e86291ab12ebce5c6'
5
5
  SHA512:
6
- metadata.gz: 1b1edc99a8b3e7257a899df34ed2b144467c1268f21877676194b138e59113d69733990ba7a0c70b1a4c51cb2861dff6e3c429cbc9f6be4a0a83c9f08a52fd22
7
- data.tar.gz: b57408a1a5d2743649538c79a269480ce2a20d21df483c8133772bbb46589d7dbff6d1c9b22d4ec329bf331f70bd5a207650bedfd83821ba2cdeb7787595621b
6
+ metadata.gz: 8df2d763b343f766f4d760e66f184d744d35ecb942562ebaf661a84c13513f714cc72597fbd2d57af2109672c659606dbd76873f1f64da32c1d7554a9789f21d
7
+ data.tar.gz: b76b4a1c25d9505604300eb305b9db94d99eec45b04ca548c5847807ce7c6db4cd1385f33f37e6fb675737c6e8094417569ebe55e8f010caae8d97652d235a94
data/Manifest.txt CHANGED
@@ -2,7 +2,17 @@ HISTORY.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ bin/csvcut
6
+ bin/csvhead
7
+ bin/csvheader
8
+ bin/csvsplit
9
+ bin/csvstat
5
10
  lib/csvutils.rb
11
+ lib/csvutils/commands/cut.rb
12
+ lib/csvutils/commands/head.rb
13
+ lib/csvutils/commands/header.rb
14
+ lib/csvutils/commands/split.rb
15
+ lib/csvutils/commands/stat.rb
6
16
  lib/csvutils/cut.rb
7
17
  lib/csvutils/head.rb
8
18
  lib/csvutils/header.rb
data/bin/csvcut ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/csvcut
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/csvcut
13
+ #
14
+
15
+ require 'csvutils'
16
+
17
+ CsvTool.cut( ARGV )
data/bin/csvhead ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/csvhead
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/csvhead
13
+ #
14
+
15
+ require 'csvutils'
16
+
17
+ CsvTool.head( ARGV )
data/bin/csvheader ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/csvheader
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/csvheader
13
+ #
14
+
15
+ require 'csvutils'
16
+
17
+ CsvTool.header( ARGV )
data/bin/csvsplit ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/csvsplit
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/csvsplit
13
+ #
14
+
15
+ require 'csvutils'
16
+
17
+ CsvTool.split( ARGV )
data/bin/csvstat ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/csvstat
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/csvstat
13
+ #
14
+
15
+ require 'csvutils'
16
+
17
+ CsvTool.stat( ARGV )
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ class CsvTool
5
+
6
+ ## command line tools
7
+ def self.cut( args )
8
+
9
+ config = { columns: [] }
10
+
11
+ parser = OptionParser.new do |opts|
12
+ opts.banner = "Usage: csvcut [OPTS] source dest"
13
+
14
+ opts.on("-c", "--columns=COLUMNS", "Name of header columns" ) do |columns|
15
+ config[:columns] = columns.split(/[,|;]/) ## allow differnt separators
16
+ end
17
+
18
+ opts.on("-h", "--help", "Prints this help") do
19
+ puts opts
20
+ exit
21
+ end
22
+ end
23
+
24
+ parser.parse!( args )
25
+
26
+ ## pp config
27
+ ## pp args
28
+
29
+ source = arg[0]
30
+ dest = arg[1]
31
+
32
+ unless arg[0] && arg[1]
33
+ puts "** error: arg(s) missing - source and dest filepath required!!! - #{args.inspect}"
34
+ exit 1
35
+ end
36
+
37
+ columns = config[:columns]
38
+
39
+ CsvUtils.cut( source, dest, *columns )
40
+ end
41
+
42
+
43
+ end # class CsvTool
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ class CsvTool
5
+
6
+ ## command line tools
7
+ def self.head( args )
8
+
9
+ config = { n: 4 }
10
+
11
+ parser = OptionParser.new do |opts|
12
+ opts.banner = "Usage: csvhead [OPTS] datafile ..."
13
+
14
+ opts.on("-n", "--num=NUM", "Number of rows" ) do |num|
15
+ config[:n] = num.to_i
16
+ end
17
+
18
+ opts.on("-h", "--help", "Prints this help") do
19
+ puts opts
20
+ exit
21
+ end
22
+ end
23
+
24
+ parser.parse!( args )
25
+
26
+ ## pp config
27
+ ## pp args
28
+
29
+ args.each do |arg|
30
+ path = arg
31
+ n = config[:n]
32
+
33
+ puts "== #{File.basename(path)} (#{File.dirname(path)}) =="
34
+ puts
35
+ CsvUtils.head( path, n: n )
36
+ puts
37
+ end # each arg
38
+ end
39
+
40
+ end # class CsvTool
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ class CsvTool
5
+
6
+ ## command line tools
7
+ def self.header( args )
8
+
9
+ config = {}
10
+
11
+ parser = OptionParser.new do |opts|
12
+ opts.banner = "Usage: csvheader [OPTS] datafile ..."
13
+
14
+ opts.on("-h", "--help", "Prints this help") do
15
+ puts opts
16
+ exit
17
+ end
18
+ end
19
+
20
+ parser.parse!( args )
21
+
22
+ ## pp config
23
+ ## pp args
24
+
25
+ args.each do |arg|
26
+ path = arg
27
+
28
+ puts "== #{File.basename(path)} (#{File.dirname(path)}) =="
29
+ puts
30
+ CsvUtils.pp_header( CsvUtils.header( path ) )
31
+ puts
32
+ end # each arg
33
+ end
34
+
35
+ end # class CsvTool
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ class CsvTool
5
+
6
+ ## command line tools
7
+ def self.split( args )
8
+
9
+ config = { columns: [] }
10
+
11
+ parser = OptionParser.new do |opts|
12
+ opts.banner = "Usage: csvsplit [OPTS] datafile ..."
13
+
14
+ opts.on("-c", "--columns=COLUMNS", "Name of header columns" ) do |columns|
15
+ config[:columns] = columns.split(/[,|;]/) ## allow differnt separators
16
+ end
17
+
18
+ opts.on("-h", "--help", "Prints this help") do
19
+ puts opts
20
+ exit
21
+ end
22
+ end
23
+
24
+ parser.parse!( args )
25
+
26
+ ## pp config
27
+ ## pp args
28
+
29
+ args.each do |arg|
30
+ path = arg
31
+ columns = config[:columns]
32
+
33
+ puts "== #{File.basename(path)} (#{File.dirname(path)}) =="
34
+ puts
35
+ CsvUtils.split( path, *columns )
36
+ puts
37
+ end
38
+
39
+
40
+ end # class CsvTool
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ class CsvTool
5
+
6
+ ## command line tools
7
+ def self.stat( args )
8
+
9
+ config = { columns: [] }
10
+
11
+ parser = OptionParser.new do |opts|
12
+ opts.banner = "Usage: csvstat [OPTS] datafile ..."
13
+
14
+ opts.on("-c", "--columns=COLUMNS", "Name of header columns" ) do |columns|
15
+ config[:columns] = columns.split(/[,|;]/) ## allow differnt separators
16
+ end
17
+
18
+ opts.on("-h", "--help", "Prints this help") do
19
+ puts opts
20
+ exit
21
+ end
22
+ end
23
+
24
+ parser.parse!( args )
25
+
26
+ ## pp config
27
+ ## pp args
28
+
29
+ args.each do |arg|
30
+ path = arg
31
+ columns = config[:columns]
32
+
33
+ puts "== #{File.basename(path)} (#{File.dirname(path)}) =="
34
+ puts
35
+ CsvUtils.stat( path, *columns )
36
+ puts
37
+ end # each arg
38
+ end
39
+
40
+
41
+ end # class CsvTool
@@ -5,8 +5,8 @@
5
5
  class CsvUtils
6
6
 
7
7
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
8
- MINOR = 1
9
- PATCH = 1
8
+ MINOR = 2
9
+ PATCH = 0
10
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
11
11
 
12
12
  def self.version
data/lib/csvutils.rb CHANGED
@@ -19,110 +19,13 @@ require 'csvutils/stat'
19
19
  require 'csvutils/header'
20
20
  require 'csvutils/head'
21
21
 
22
+ require 'csvutils/commands/head'
23
+ require 'csvutils/commands/header'
24
+ require 'csvutils/commands/stat'
25
+ require 'csvutils/commands/cut'
26
+ require 'csvutils/commands/split'
22
27
 
23
28
 
24
29
 
25
- class CsvTool
26
-
27
- ## command line tools
28
- def self.header( args )
29
-
30
- config = {}
31
-
32
- parser = OptionParser.new do |opts|
33
- opts.banner = "Usage: csvheader [OPTS] datafile ..."
34
-
35
- opts.on("-h", "--help", "Prints this help") do
36
- puts opts
37
- exit
38
- end
39
- end
40
-
41
- parser.parse!( args )
42
-
43
- ## pp config
44
- ## pp args
45
-
46
- args.each do |arg|
47
- path = arg
48
-
49
- puts "== #{File.basename(path)} (#{File.dirname(path)}) =="
50
- puts
51
- CsvUtils.pp_header( CsvUtils.header( path ) )
52
- puts
53
- end # each arg
54
- end
55
-
56
-
57
- def self.stat( args )
58
-
59
- config = { columns: [] }
60
-
61
- parser = OptionParser.new do |opts|
62
- opts.banner = "Usage: csvstat [OPTS] datafile ..."
63
-
64
- opts.on("-c", "--columns=COLUMNS", "Name of header columns" ) do |columns|
65
- config[:columns] = columns.split(/[,|;]/) ## allow differnt separators
66
- end
67
-
68
- opts.on("-h", "--help", "Prints this help") do
69
- puts opts
70
- exit
71
- end
72
- end
73
-
74
- parser.parse!( args )
75
-
76
- ## pp config
77
- ## pp args
78
-
79
- args.each do |arg|
80
- path = arg
81
- columns = config[:columns]
82
-
83
- puts "== #{File.basename(path)} (#{File.dirname(path)}) =="
84
- puts
85
- CsvUtils.stat( path, *columns )
86
- puts
87
- end # each arg
88
- end
89
-
90
-
91
- def self.head( args )
92
-
93
- config = { n: 4 }
94
-
95
- parser = OptionParser.new do |opts|
96
- opts.banner = "Usage: csvhead [OPTS] datafile ..."
97
-
98
- opts.on("-n", "--num=NUM", "Number of rows" ) do |num|
99
- config[:n] = num.to_i
100
- end
101
-
102
- opts.on("-h", "--help", "Prints this help") do
103
- puts opts
104
- exit
105
- end
106
- end
107
-
108
- parser.parse!( args )
109
-
110
- ## pp config
111
- ## pp args
112
-
113
- args.each do |arg|
114
- path = arg
115
- n = config[:n]
116
-
117
- puts "== #{File.basename(path)} (#{File.dirname(path)}) =="
118
- puts
119
- CsvUtils.head( path, n: n )
120
- puts
121
- end # each arg
122
- end
123
-
124
-
125
- end # class CsvTool
126
-
127
30
 
128
31
  puts CsvUtils.banner # say hello
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csvutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
@@ -41,7 +41,12 @@ dependencies:
41
41
  description: csvutils - tools 'n' scripts for working with comma-separated values
42
42
  (csv) datafiles - the world's most popular tabular date interchange format in text
43
43
  email: wwwmake@googlegroups.com
44
- executables: []
44
+ executables:
45
+ - csvcut
46
+ - csvhead
47
+ - csvheader
48
+ - csvsplit
49
+ - csvstat
45
50
  extensions: []
46
51
  extra_rdoc_files:
47
52
  - HISTORY.md
@@ -52,7 +57,17 @@ files:
52
57
  - Manifest.txt
53
58
  - README.md
54
59
  - Rakefile
60
+ - bin/csvcut
61
+ - bin/csvhead
62
+ - bin/csvheader
63
+ - bin/csvsplit
64
+ - bin/csvstat
55
65
  - lib/csvutils.rb
66
+ - lib/csvutils/commands/cut.rb
67
+ - lib/csvutils/commands/head.rb
68
+ - lib/csvutils/commands/header.rb
69
+ - lib/csvutils/commands/split.rb
70
+ - lib/csvutils/commands/stat.rb
56
71
  - lib/csvutils/cut.rb
57
72
  - lib/csvutils/head.rb
58
73
  - lib/csvutils/header.rb