easy_sheet_io 0.4.9 → 0.4.9.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.
data/lib/to_csv.rb CHANGED
@@ -1,72 +1,72 @@
1
- require "daru"
2
- require "rover"
3
-
4
- class Daru::DataFrame
5
- def to_csv()
6
- a = self.to_a.transpose
7
-
8
- ans = self.map(&:name).join ","
9
- self.to_a[0].each do |item|
10
- ans += "\n"
11
- ans += item.map{|k, v| v}.join(",")
12
- end
13
-
14
- return ans
15
- end
16
-
17
- def write_csv(path, encoding: nil)
18
- enc = encoding.nil? ? "" : ":#{encoding}"
19
- open(path, "w#{enc}") { _1.write to_csv }
20
- end
21
-
22
- # To avoid bug about adding column to Daru::DataFrame
23
- def add_vector(vecname, vec)
24
- self[vecname] = vec
25
- self.rename_vectors({vecname => vecname})
26
- end
27
-
28
- ### エンコード関連 ###
29
- # vector_i番目のヘッダー名を読めるようにエンコード
30
- def encode_vector_name(vector_i)
31
- if self.vectors.to_a[vector_i].is_a?(String)
32
- self.vectors.to_a[vector_i].encode Encoding::UTF_8, Encoding::Windows_31J
33
- end
34
- end
35
-
36
- # すべての列に対し上記を実施
37
- def encode_vectors!
38
- self.vectors = Daru::Index.new(Range.new(0, self.vectors.size-1).map {|i| encode_vector_name i })
39
- end
40
-
41
- # ver.0.3.8~ Convert Daru::DF encoding
42
- def convert_enc!(from: "cp932", to: "utf-8")
43
- self.vectors.each do |col|
44
- self[col] = self[col].each {|val| val.encode!(to, from_encoding: from) if val.is_a?(String)}
45
- end
46
-
47
- self.encode_vectors!
48
- end
49
- #####################
50
-
51
- # rover not suppoted yet about indexing
52
- def set_index!(indexcolumn)
53
- self.index = self[indexcolumn]
54
- end
55
-
56
- # To revice pivot index
57
- def simplify_multi_index(vector_names_ary)
58
- self.vectors = Daru::Index.new(vector_names_ary)
59
- self.index = Daru::Vector.new(self.index.to_a.map{_1[0]})
60
- end
61
-
62
- alias_method :addvec, :add_vector
63
- end
64
-
65
- class Rover::DataFrame
66
- # Rover#to_csv is already exist.
67
-
68
- def write_csv(path, encoding: nil)
69
- enc = encoding.nil? ? "" : ":#{encoding}"
70
- open(path, "w#{enc}") {|f| f.write self.to_csv}
71
- end
72
- end
1
+ require "daru"
2
+ require "rover"
3
+
4
+ class Daru::DataFrame
5
+ def to_csv()
6
+ a = self.to_a.transpose
7
+
8
+ ans = self.map(&:name).join ","
9
+ self.to_a[0].each do |item|
10
+ ans += "\n"
11
+ ans += item.map{|k, v| v}.join(",")
12
+ end
13
+
14
+ return ans
15
+ end
16
+
17
+ def write_csv(path, encoding: nil)
18
+ enc = encoding.nil? ? "" : ":#{encoding}"
19
+ open(path, "w#{enc}") { _1.write to_csv }
20
+ end
21
+
22
+ # To avoid bug about adding column to Daru::DataFrame
23
+ def add_vector(vecname, vec)
24
+ self[vecname] = vec
25
+ self.rename_vectors({vecname => vecname})
26
+ end
27
+
28
+ ### エンコード関連 ###
29
+ # vector_i番目のヘッダー名を読めるようにエンコード
30
+ def encode_vector_name(vector_i)
31
+ if self.vectors.to_a[vector_i].is_a?(String)
32
+ self.vectors.to_a[vector_i].encode Encoding::UTF_8, Encoding::Windows_31J
33
+ end
34
+ end
35
+
36
+ # すべての列に対し上記を実施
37
+ def encode_vectors!
38
+ self.vectors = Daru::Index.new(Range.new(0, self.vectors.size-1).map {|i| encode_vector_name i })
39
+ end
40
+
41
+ # ver.0.3.8~ Convert Daru::DF encoding
42
+ def convert_enc!(from: "cp932", to: "utf-8")
43
+ self.vectors.each do |col|
44
+ self[col] = self[col].each {|val| val.encode!(to, from_encoding: from) if val.is_a?(String)}
45
+ end
46
+
47
+ self.encode_vectors!
48
+ end
49
+ #####################
50
+
51
+ # rover not suppoted yet about indexing
52
+ def set_index!(indexcolumn)
53
+ self.index = self[indexcolumn]
54
+ end
55
+
56
+ # To revice pivot index
57
+ def simplify_multi_index(vector_names_ary)
58
+ self.vectors = Daru::Index.new(vector_names_ary)
59
+ self.index = Daru::Vector.new(self.index.to_a.map{_1[0]})
60
+ end
61
+
62
+ alias_method :addvec, :add_vector
63
+ end
64
+
65
+ class Rover::DataFrame
66
+ # Rover#to_csv is already exist.
67
+
68
+ def write_csv(path, encoding: nil)
69
+ enc = encoding.nil? ? "" : ":#{encoding}"
70
+ open(path, "w#{enc}") {|f| f.write self.to_csv}
71
+ end
72
+ 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.9
4
+ version: 0.4.9.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-11-11 00:00:00.000000000 Z
11
+ date: 2026-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daru
@@ -80,8 +80,8 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.3.0
83
- description: A simple way to Open .csv, .xls, .xlsx files. You can convert it to 2D
84
- array, hash, data frame.
83
+ description: "**Deprecated** Use yomise instead. A simple way to Open .csv, .xls,
84
+ .xlsx files. You can convert it to 2D array, hash, data frame."
85
85
  email:
86
86
  - shun_yamaguchi_tc@live.jp
87
87
  executables: []
@@ -126,8 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
- rubygems_version: 3.2.3
129
+ rubygems_version: 3.4.19
130
130
  signing_key:
131
131
  specification_version: 4
132
- summary: A simple way to Open .csv, .xls, .xlsx files.
132
+ summary: "**Deprecated** Use yomise instead."
133
133
  test_files: []