easy_sheet_io 0.4.5 → 0.4.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5836501206e6f5e817320e5b3902b8149320fb3298cd7aed7fc6e7d46c4abcf8
4
- data.tar.gz: 9dcbc71d2fcc52869a576a67b511f70bffe92f2503287ba79cd8df7b507a42ac
3
+ metadata.gz: 685887cb42121abd31ee9247b6a6567853d69990b1e00ac8332a1e6a6b7f6eb7
4
+ data.tar.gz: 5b1871486be2cfce04639ec8ab49bd64c074f0cfd81f967c91f7242ce27d9b0a
5
5
  SHA512:
6
- metadata.gz: 65b0d5662c5f48da2ac4335fe0900ba07469d3e77eb7efbd0f372e5a3403dfb0daa64f63e1ad72563c871054ce024210e711880844525a6debf0dd03bff3b4dd
7
- data.tar.gz: 5ba3eac9ce9660853ba9f0e181504baf57a20c2a1041cc9d4e681be888946f5c23a53a31ec6eeeea230f1217b1adbdbf9a4ac06f426e8ed395282cb8f009e0d3
6
+ metadata.gz: 6509dce129c5732759c37ccdb8168666b1b39be910b56a9f175e076f5ea7c8d0924f891db0bfa2eb7810e1b631a88989b1d780baf8607039824c33398e14f504
7
+ data.tar.gz: e3135fe8dfb8601557fccd0a0c3b7185e86cc0e27a4b7cc43f230d42090e80a9b0003851c68731a6a66de2709b88a21bc4bea0a5d74a797e145c33252c67f503
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EasySheetIo
4
- VERSION = "0.4.5"
4
+ VERSION = "0.4.6.1"
5
5
  end
data/lib/easy_sheet_io.rb CHANGED
@@ -21,6 +21,9 @@ module EasySheetIo
21
21
  # **opt candidate= line_from: 1, header: 0
22
22
  # ver. 0.3.8~ default format=:daru
23
23
  def read_csv(path, format: :daru, encoding: "utf-8", col_sep: ",", **opt)
24
+ ## TODO.. index: option that designate column number to generate DF index.
25
+ ## That is, revicing set_index method.
26
+
24
27
  # Get 2D Array
25
28
  begin
26
29
  csv = CSV.parse(File.open(path, encoding: encoding, &:read), col_sep: col_sep)
@@ -35,9 +38,13 @@ module EasySheetIo
35
38
  return csv
36
39
  elsif format.to_s == "hash"
37
40
  return to_hash(csv, **opt)
38
- else # include format.nil? ... convert to daru df.
41
+ else # include format.nil? (in this case, convert to Daru::DF).
39
42
  ans = to_df(to_hash(csv, **opt), format: format)
40
- ans.convert_enc!(from: encoding, to: "utf-8") # if encoding != "utf-8"
43
+ ans.convert_enc!(from: encoding, to: "utf-8", format: format) # if encoding != "utf-8"
44
+
45
+ # Setting index.. rover not supported yet
46
+ ans.set_index! if format.to_s == "daru" || format.nil?
47
+
41
48
  return ans
42
49
  end
43
50
  end
@@ -62,6 +69,7 @@ module EasySheetIo
62
69
  def to_hash(array2d, line_from: 1, line_until: nil, line_ignored: nil,
63
70
  header: 0, symbol_header: false,
64
71
  replaced_by_nil: [], analyze_type: true)
72
+ ## TODO.. column_from: , column_until:
65
73
 
66
74
  # Define Read Range------------
67
75
  lfrom, luntil = line_from, line_until
data/lib/to_csv.rb CHANGED
@@ -27,21 +27,29 @@ class Daru::DataFrame
27
27
 
28
28
  # vector_i番目のヘッダー名を読めるようにエンコード
29
29
  def encode_vector_name(vector_i)
30
- self.vectors.to_a[vector_i].encode Encoding::UTF_8, Encoding::Windows_31J
30
+ if self.vectors.to_a[vector_i].is_a?(String)
31
+ self.vectors.to_a[vector_i].encode Encoding::UTF_8, Encoding::Windows_31J
32
+ end
31
33
  end
32
34
 
33
- # すべての列に対し実施
34
- def encode_vectors
35
+ # すべての列に対し上記を実施
36
+ def encode_vectors!
35
37
  self.vectors = Daru::Index.new(Range.new(0, self.vectors.size-1).map {|i| encode_vector_name i })
36
38
  end
37
39
 
38
40
  # ver.0.3.8~ Convert Daru::DF encoding
39
- def convert_enc!(from: "cp932", to: "utf-8")
41
+ def convert_enc!(from: "cp932", to: "utf-8", format: nil)
40
42
  self.vectors.each do |col|
41
43
  self[col] = self[col].each {|val| val.encode!(to, from_encoding: from) if val.is_a?(String)}
42
44
  end
45
+
46
+ self.encode_vectors! if format.to_s == "daru" || format.nil?
43
47
  end
44
48
 
49
+ # rover not suppoted yet
50
+ def set_index!
51
+ self.index = self[0]
52
+ end
45
53
 
46
54
  alias_method :addvec, :add_vector
47
55
  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.5
4
+ version: 0.4.6.1
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-06 00:00:00.000000000 Z
11
+ date: 2023-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daru