csv_tools 0.1.1 → 0.1.2

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: 90e76e93fa5688fed25b5c7870d318929bfc505e
4
- data.tar.gz: 544f99192cddc9152eb8787844688ac6844acc79
3
+ metadata.gz: 30160523254a186a9cc74aec319ab0c1f0e75dde
4
+ data.tar.gz: 622c916270ec61804b32101cb3d1f0bb38a89a31
5
5
  SHA512:
6
- metadata.gz: 5a350262ab443cdbe23a7f1cd8c80a51187471f116da264d1571b9bf5bc529eb2891b7082913c48fcbacee4a116d7befd3646d8da39ef2b6e64e23500e6c5c38
7
- data.tar.gz: 123b2e8424f7d6a169f2c775cd6e07c4749bca58d37ab6a3e95e5e9781420639da5eed9998fc70cdad963a4d4b42ee0d257e38bc1338a10f2d25eab5a2b4df78
6
+ metadata.gz: 06e940c6986cd29d6bde9630fb6050d4b8097b589a1db6a7ba1bf66da5a3821a3a42dc162ff6de47bb290492a720c8f8fa7ffcd3c00fd83ed6cd67b408fe530c
7
+ data.tar.gz: 440f0c0c10947cc307d6ae4a0ed5f9a1564be8413511b0d1289d595bbd6fbefef737b41b9794dbde832f938ab6e358e9f9373392e8d3742a5ee8bd1f17831f39
data/README.md CHANGED
@@ -6,6 +6,7 @@ At the moment, the following operations are supported:
6
6
  * Selecting specific columns (by index)
7
7
  * Filter rows, based on a specific field
8
8
  * Join two CSV files on a single column
9
+ * Enumerate the CSV headers (convenient for CSV files with many columns)
9
10
 
10
11
  ## Installation
11
12
 
@@ -71,3 +72,16 @@ student-id,name,Assignment 1,Assignment 2,Test
71
72
  2,Bob,53,61,58
72
73
  3,Rob,85,88,87
73
74
  ```
75
+
76
+ #### Enum
77
+
78
+ When working with CSV that have many columns, it is convenient to be able to
79
+ enumerate the column-headers.
80
+
81
+ ```
82
+ $ csv_enum marks.csv
83
+ 0 : student-id
84
+ 1 : Assignment 1
85
+ 2 : Assignment 2
86
+ 3 : Test
87
+ ```
data/bin/csv_enum ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'csv'
4
+
5
+ if ARGV.length != 1
6
+ abort("Usage: #{File.basename($0)} CSV-FILE")
7
+ end
8
+
9
+ CSV.open(ARGV[0], {headers: true}) do |csv|
10
+ csv.readline # Read the header line
11
+ csv.headers.each_with_index { |header, i| puts "#{i}\t: #{header}"}
12
+ end
@@ -1,3 +1,3 @@
1
1
  module CSVTools
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joey Freund
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-13 00:00:00.000000000 Z
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,6 +42,7 @@ description: Manipulate CSV files as if they were SQL tables.
42
42
  email:
43
43
  - joeyfreund@gmail.com
44
44
  executables:
45
+ - csv_enum
45
46
  - csv_filter
46
47
  - csv_join
47
48
  - csv_select
@@ -53,6 +54,7 @@ files:
53
54
  - LICENSE.txt
54
55
  - README.md
55
56
  - Rakefile
57
+ - bin/csv_enum
56
58
  - bin/csv_filter
57
59
  - bin/csv_join
58
60
  - bin/csv_select