easy_sheet_io 0.4.6.1 → 0.4.6.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 +4 -4
- data/lib/easy_sheet_io/version.rb +1 -1
- data/lib/easy_sheet_io.rb +6 -4
- data/lib/to_csv.rb +5 -3
- 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: '0489a9c987e6b88c82136b5d22a6645e95935c6015118db1246afa8794141d53'
|
4
|
+
data.tar.gz: 28462d03acd63beb8d36937aef938028e2a66c83f759e965afd888b97dc6645a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 401597fa2203db419f00b38ee1e75427946885c581bf62bb8b2026531975376ae8863510829a702409984a5a7a8b3d1b02d9a29eef6645e187a3a27139decefc
|
7
|
+
data.tar.gz: eaa9893d8540dce0a4c64433e8e8c6eb4cb4223eb39c8ff39c6827524016920ddb6d74ac7cca8e86a5636925b899cbacb6966d9f6caac339e96c4032fac3c8b0
|
data/lib/easy_sheet_io.rb
CHANGED
@@ -20,7 +20,7 @@ module EasySheetIo
|
|
20
20
|
# ##Generate Array from CSV File, and convert it to Hash or DataFrame.
|
21
21
|
# **opt candidate= line_from: 1, header: 0
|
22
22
|
# ver. 0.3.8~ default format=:daru
|
23
|
-
def read_csv(path, format: :daru, encoding: "utf-8", col_sep: ",", **opt)
|
23
|
+
def read_csv(path, format: :daru, encoding: "utf-8", col_sep: ",", index: nil, **opt)
|
24
24
|
## TODO.. index: option that designate column number to generate DF index.
|
25
25
|
## That is, revicing set_index method.
|
26
26
|
|
@@ -40,10 +40,12 @@ module EasySheetIo
|
|
40
40
|
return to_hash(csv, **opt)
|
41
41
|
else # include format.nil? (in this case, convert to Daru::DF).
|
42
42
|
ans = to_df(to_hash(csv, **opt), format: format)
|
43
|
-
ans.convert_enc!(from: encoding, to: "utf-8", format: format) # if encoding != "utf-8"
|
44
43
|
|
45
|
-
# Setting index.. rover not supported yet
|
46
|
-
|
44
|
+
# Converting Encode and Setting index.. rover not supported yet
|
45
|
+
if format.to_s == "daru" || format.nil?
|
46
|
+
ans.convert_enc!(from: encoding, to: "utf-8")
|
47
|
+
ans.set_index! if index
|
48
|
+
end
|
47
49
|
|
48
50
|
return ans
|
49
51
|
end
|
data/lib/to_csv.rb
CHANGED
@@ -25,6 +25,7 @@ class Daru::DataFrame
|
|
25
25
|
self.rename_vectors({vecname => vecname})
|
26
26
|
end
|
27
27
|
|
28
|
+
### エンコード関連 ###
|
28
29
|
# vector_i番目のヘッダー名を読めるようにエンコード
|
29
30
|
def encode_vector_name(vector_i)
|
30
31
|
if self.vectors.to_a[vector_i].is_a?(String)
|
@@ -38,15 +39,16 @@ class Daru::DataFrame
|
|
38
39
|
end
|
39
40
|
|
40
41
|
# ver.0.3.8~ Convert Daru::DF encoding
|
41
|
-
def convert_enc!(from: "cp932", to: "utf-8"
|
42
|
+
def convert_enc!(from: "cp932", to: "utf-8")
|
42
43
|
self.vectors.each do |col|
|
43
44
|
self[col] = self[col].each {|val| val.encode!(to, from_encoding: from) if val.is_a?(String)}
|
44
45
|
end
|
45
46
|
|
46
|
-
self.encode_vectors!
|
47
|
+
self.encode_vectors!
|
47
48
|
end
|
49
|
+
#####################
|
48
50
|
|
49
|
-
# rover not suppoted yet
|
51
|
+
# rover not suppoted yet about indexing
|
50
52
|
def set_index!
|
51
53
|
self.index = self[0]
|
52
54
|
end
|
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.4.6.
|
4
|
+
version: 0.4.6.2
|
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: 2023-09-
|
11
|
+
date: 2023-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: daru
|