我正在提取 CSV 数据,然后将其存储为数组。我需要将这些数组作为单个哈希返回。
这将允许我为每个索引使用一个键,而不是使用索引号,但我在让它工作时遇到了问题。它记录一个错误,指出参数数量错误。
有什么想法我哪里出错了吗?
代码:
ref = Array.new
summary = Array.new
pri = Array.new
state = Array.new
estdur = Array.new
notes = Array.new
supporter = Array.new
bz = Array.new
project = Array.new
team = Array.new
hashed = Hash.new
csvPath = "#{File.dirname(__FILE__)}"+"/../modules/csv.csv"
CSV.foreach(csvPath, :headers=>true, :header_converters=>:symbol) do |row|
ref << row [ :feature ]
summary << row [ :Summary ]
pri << row [ :Pri ]
state << row [ :State ]
estdur << row [ :EstDur ]
notes << row [ :Notes ]
supporter << row [ :Supporter ]
bz << row [ :BZ ]
project << row [ :Project ]
team << row [ :Team ]
end
return hashed[
"ref", ref,
"summary", summary,
"pri", pri,
"state", state,
"estDur", estdur,
"notes", notes,
"supporter", supporter,
"bz", bz,
"project", project,
"team", team
]