easy_sheet_io 0.3.1 → 0.3.4
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/Gemfile.lock +1 -1
- data/lib/easy_sheet_io/version.rb +1 -1
- data/lib/easy_sheet_io.rb +6 -6
- 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: c6c3311ca8c795c56410c546a6af080c4fa861a11ce8e675b16d73b4d821ba3f
|
4
|
+
data.tar.gz: 8b191f063c3726f294524e3c2523a6c4e1538f98170ac2b00267d24000f99244
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0abaf7b3add7992c68de152a6320aaee4a9e3d08236741a99156af3765caa24f2c38c96c8678c9acb0a5357cf9c8a30cf3b16c9ebdd56b9e5d7e1aa6c8a7b998
|
7
|
+
data.tar.gz: f5a1ba3a6af715ac9f7df205376bb9b2f2df853695a3a9c6e3852ea7117c4c1876c278c91de641085e16edbd15ec93ee183d86d1c1480619d8d8dece1b72bdac
|
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: false)
|
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
|
@@ -182,7 +182,7 @@ module EasySheetIo
|
|
182
182
|
temp = /^\s*$/ === item ? "column#{i}" : item.gsub(/\s+/, "")
|
183
183
|
/^\d+$/ === temp ? "column#{i}" : temp
|
184
184
|
else
|
185
|
-
item
|
185
|
+
item.to_s
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
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.4
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|