easy_sheet_io 0.3.2 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/easy_sheet_io/version.rb +1 -1
- data/lib/easy_sheet_io.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eb1e608ff7813cad651c93966644a89c2562595ffb3a5da4af5f76969face49
|
4
|
+
data.tar.gz: 65ca712fd6b04385518aa2af73a5874664a666da30900edc650f006ca765f147
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4df72848af130d1d1c0c16eb0bc3324d0bb28cc706fb6cfbe295fe4ba4d6c106e3c82585a4b19836e42daa38a27ae161714034305ab36d8a358f48fc856da2f9
|
7
|
+
data.tar.gz: 7b9b9c0f6b20a872f18b1b87844ce25a813ce16d3eadd877df9186471915dc1e82c472fee3d67cf9976bfb5805624525650ac50d4cfe0775bc27939f09c87edb
|
data/Gemfile.lock
CHANGED
data/lib/easy_sheet_io.rb
CHANGED
@@ -23,7 +23,7 @@ module EasySheetIo
|
|
23
23
|
# Get 2D Array
|
24
24
|
begin
|
25
25
|
csv = CSV.parse(File.open(path, encoding: encoding, &:read), col_sep: col_sep)
|
26
|
-
rescue
|
26
|
+
rescue
|
27
27
|
# Try Another Encoding
|
28
28
|
puts "Fail Encoding #{encoding}. Trying cp932..."
|
29
29
|
csv = CSV.parse(File.open(path, encoding: "cp932", &:read), col_sep: col_sep)
|
@@ -51,7 +51,7 @@ module EasySheetIo
|
|
51
51
|
## Option line_ignored is not implemented yet.
|
52
52
|
def to_hash(array2d, line_from: 1, line_until: nil, line_ignored: nil,
|
53
53
|
header: 0, symbol_header: false,
|
54
|
-
|
54
|
+
replaced_by_nil: [], analyze_type: true)
|
55
55
|
|
56
56
|
# Define Read Range------------
|
57
57
|
lfrom, luntil = line_from, line_until
|
@@ -67,7 +67,7 @@ module EasySheetIo
|
|
67
67
|
# Define Data Array------------
|
68
68
|
output = array2d[lfrom...luntil]
|
69
69
|
output_transpose = output[0].zip(*output[1..])
|
70
|
-
output_transpose = fix_array(output_transpose,
|
70
|
+
output_transpose = fix_array(output_transpose, replaced_by_nil, analyze_type)
|
71
71
|
# -----------------------------
|
72
72
|
|
73
73
|
# Define Header----------------
|
@@ -126,12 +126,12 @@ module EasySheetIo
|
|
126
126
|
end
|
127
127
|
|
128
128
|
# Fix Array (Replace specific values to nil, recognize value type and cast values to the type.)
|
129
|
-
def fix_array(array2d,
|
129
|
+
def fix_array(array2d, replaced_by_nil, analyze_type)
|
130
130
|
ans = array2d
|
131
131
|
|
132
132
|
## Replace Blank or User-Selected Value
|
133
133
|
ans = ans.map do |column|
|
134
|
-
column.map { |cell|
|
134
|
+
column.map { |cell| replaced_by_nil.include?(cell) || /^\s*$/ === cell ? nil : cell }
|
135
135
|
end
|
136
136
|
|
137
137
|
## Replace Number Values to Integer or Float
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_sheet_io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- show-o-atakun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|