tabular 0.3.5 → 0.4.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 +4 -4
- data/README +1 -0
- data/Rakefile +0 -15
- data/lib/tabular/table.rb +1 -1
- data/lib/tabular/tables/file_reading.rb +7 -4
- data/lib/tabular/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24ea155d9007a4c02fb223ef654916c81ca40a8a
|
4
|
+
data.tar.gz: 67bf2a31432324f4d9dd1a4545c91d925df0ed95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97d41fd3815402be84700509fc51db7ff53ed392327c2168faf4fb5f8e389e0d5861b1d154b9ada63dd445410ca396a4beb7d7d804f473e6da393955175c8cc8
|
7
|
+
data.tar.gz: 9202f7626394eaf0b6af0fcb3c2cb202f6e507390b14a8b1d6f849b586f73cd1f715e73c4a9ddf72ac1c7c2c62aae8fe101434fd48ab54adac5f0ed7f7b9c15c
|
data/README
CHANGED
@@ -62,6 +62,7 @@ There's basic test coverage. More comprehensive test coverage needs to be extrac
|
|
62
62
|
|
63
63
|
Changes
|
64
64
|
-------
|
65
|
+
0.4.0 rchristensen: Add sheet argument to Table.read
|
65
66
|
0.3.0 Revise Table creation methods to something sensible. Use Roo to read
|
66
67
|
spreadsheets. Support for xlsx.
|
67
68
|
0.2.7 Add Table#to_space_delimited for space-padded fixed layout
|
data/Rakefile
CHANGED
@@ -1,21 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
3
|
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gemspec|
|
7
|
-
gemspec.name = "tabular"
|
8
|
-
gemspec.summary = "Read, write, and manipulate CSV, tab-delimited and Excel data"
|
9
|
-
gemspec.description = "Tabular is a Ruby library for reading, writing, and manipulating CSV, tab-delimited and Excel data."
|
10
|
-
gemspec.email = "scott.willson@gmail.cpm"
|
11
|
-
gemspec.homepage = "http://github.com/scottwillson/tabular"
|
12
|
-
gemspec.authors = ["Scott Willson"]
|
13
|
-
end
|
14
|
-
Jeweler::GemcutterTasks.new
|
15
|
-
rescue LoadError
|
16
|
-
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
17
|
-
end
|
18
|
-
|
19
4
|
require 'rake/testtask'
|
20
5
|
Rake::TestTask.new(:test) do |test|
|
21
6
|
test.libs << 'lib' << 'test'
|
data/lib/tabular/table.rb
CHANGED
@@ -5,14 +5,17 @@ module Tabular
|
|
5
5
|
# Assumes .txt = tab-delimited, .csv = CSV, .xls = Excel. Assumes first row is the header.
|
6
6
|
# Normalizes column names to lower-case with underscores.
|
7
7
|
# +format+ : :csv, :txt, or :xls
|
8
|
+
# +sheet+: integer, specifies the desired worksheet of an .xls/xlsx file, 0 by default.
|
8
9
|
# Returns Array of Arrays
|
9
|
-
def read(file, format = nil)
|
10
|
+
def read(file, format = nil, sheet = nil)
|
10
11
|
file_path = to_file_path(file)
|
11
12
|
format ||= format_from(format, file_path)
|
12
13
|
|
13
14
|
self.rows = case format
|
14
15
|
when :xls, :xlsx
|
15
|
-
|
16
|
+
# Set to first sheet if undefined.
|
17
|
+
sheet ||= 0
|
18
|
+
read_spreadsheet file_path, format, sheet
|
16
19
|
when :txt
|
17
20
|
read_txt file_path
|
18
21
|
when :csv
|
@@ -52,7 +55,7 @@ module Tabular
|
|
52
55
|
file_path
|
53
56
|
end
|
54
57
|
|
55
|
-
def read_spreadsheet(file_path, format)
|
58
|
+
def read_spreadsheet(file_path, format, sheet)
|
56
59
|
require "roo"
|
57
60
|
|
58
61
|
if format == :xls
|
@@ -64,7 +67,7 @@ module Tabular
|
|
64
67
|
|
65
68
|
# Row#to_a coerces Excel data to Strings, but we want Dates and Numbers
|
66
69
|
data = []
|
67
|
-
excel.sheet(
|
70
|
+
excel.sheet(sheet).each do |excel_row|
|
68
71
|
data << excel_row.inject([]) { |row, cell| row << cell; row }
|
69
72
|
end
|
70
73
|
data
|
data/lib/tabular/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Willson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: roo
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
86
|
rubyforge_project:
|
87
|
-
rubygems_version: 2.4.
|
87
|
+
rubygems_version: 2.4.8
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: Read, write, and manipulate CSV, tab-delimited and Excel data
|