mymatrix 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/loader_csv.rb +5 -4
- data/lib/loader_txt.rb +1 -1
- data/lib/mymatrix/version.rb +1 -1
- data/pkg/mymatrix-0.0.9.gem +0 -0
- data/spec/csv.csv +1 -2
- data/spec/mymatrix_spec.rb +15 -2
- metadata +3 -2
data/lib/loader_csv.rb
CHANGED
@@ -15,14 +15,14 @@ class LoaderCsv < FileIO
|
|
15
15
|
else
|
16
16
|
#1.9以上の場合
|
17
17
|
require 'csv'
|
18
|
-
Encoding.default_external = opts[:encode]
|
18
|
+
#Encoding.default_external = opts[:encode]
|
19
19
|
csv = CSV
|
20
20
|
end
|
21
21
|
out = []
|
22
22
|
i= 0
|
23
23
|
syspath = self.encodePath(file)
|
24
|
-
csv.foreach(syspath, {:row_sep => "\r\n", :encoding => opts[:encode]}) do |row|
|
25
|
-
|
24
|
+
#csv.foreach(syspath, {:row_sep => "\r\n", :encoding => opts[:encode]}) do |row|
|
25
|
+
csv.foreach(syspath, {:encoding => opts[:encode]}) do |row|
|
26
26
|
if(opts[:offset])
|
27
27
|
if(opts[:offset] < i)
|
28
28
|
next
|
@@ -33,7 +33,8 @@ class LoaderCsv < FileIO
|
|
33
33
|
row.each do |cell|
|
34
34
|
cell = cell.to_s
|
35
35
|
cell ||= ''
|
36
|
-
|
36
|
+
p cell
|
37
|
+
#cell = MyMatrix.toutf8(cell)
|
37
38
|
#cell = cell.gsub(/^\"/, "")
|
38
39
|
#cell = cell.gsub(/\"$/, "")
|
39
40
|
#"
|
data/lib/loader_txt.rb
CHANGED
data/lib/mymatrix/version.rb
CHANGED
Binary file
|
data/spec/csv.csv
CHANGED
data/spec/mymatrix_spec.rb
CHANGED
@@ -99,8 +99,12 @@ describe MyMatrix do
|
|
99
99
|
mx[1][0].should == 'ダブル"クオーテーション'
|
100
100
|
mx[1][1].should == 'カン,マ'
|
101
101
|
mx[1][2].should == 'aaa'
|
102
|
-
|
103
|
-
|
102
|
+
end
|
103
|
+
it 'UTF-8形式のcsvファイルが読めること' do
|
104
|
+
mx = makecsv_utf
|
105
|
+
mx[0][0].should == ''
|
106
|
+
mx[0][2].should == '大阪'
|
107
|
+
mx.val(mx[0], 'b').should == '奈良'
|
104
108
|
end
|
105
109
|
it 'tsvファイルを読めること' do
|
106
110
|
mx = MyMatrix.new('spec/jptest.txt')
|
@@ -338,6 +342,15 @@ def makecsv
|
|
338
342
|
mx = MyMatrix.new('spec/csv.csv')
|
339
343
|
return mx
|
340
344
|
end
|
345
|
+
def makecsv_utf
|
346
|
+
open('spec/csv.csv', 'w') do |fo|
|
347
|
+
fo.write("a,b,c\r\n")
|
348
|
+
fo.write(',奈良,大阪')
|
349
|
+
fo.write("\r\n")
|
350
|
+
end
|
351
|
+
mx = MyMatrix.new('spec/csv.csv', :encode => 'utf-8')
|
352
|
+
return mx
|
353
|
+
end
|
341
354
|
def makecsv_norow
|
342
355
|
open('spec/csv.csv', 'w') do |fo|
|
343
356
|
fo.write("a,b,c\r\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mymatrix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- pkg/mymatrix-0.0.4.gem
|
83
83
|
- pkg/mymatrix-0.0.5.gem
|
84
84
|
- pkg/mymatrix-0.0.8.gem
|
85
|
+
- pkg/mymatrix-0.0.9.gem
|
85
86
|
- spec/csv.csv
|
86
87
|
- spec/csv.csv.txt
|
87
88
|
- spec/csv_test.csv
|