回答編集履歴

1

コードの修正

2016/02/13 12:21

投稿

K_S_
K_S_

スコア419

test CHANGED
@@ -4,23 +4,33 @@
4
4
 
5
5
  hash_ary=[]
6
6
 
7
+ loop_count = 0
8
+
7
9
  File.open("humans.csv","r") do |f|
8
10
 
9
11
  f.each_line do |line|
10
12
 
11
- ary = line.chomp.split(",")
13
+ if loop_count == 0 then
12
14
 
13
- hash_ary_c = {}
15
+ next
14
16
 
15
- hash_ary_c["namae"]=ary[0]
17
+ end
16
18
 
17
- hash_ary_c["seibetu"]=ary[1]
19
+ ary = line.chomp.split(",")
18
20
 
19
- hash_ary_c["toshi"]=ary[2]
21
+ hash_ary_c = {}
20
22
 
21
- hash_ary.push(hash_ary_c)
23
+ hash_ary_c["namae"]=ary[0]
22
24
 
25
+ hash_ary_c["seibetu"]=ary[1]
26
+
27
+ hash_ary_c["toshi"]=ary[2]
28
+
29
+ hash_ary.push(hash_ary_c)
30
+
31
+ loop_count += 1
32
+
23
- end
33
+ end
24
34
 
25
35
  end
26
36