Hello,
I'm writing an application that pulls values out of an excel spreadsheet and then stores those values in a hash using the version number as a key. Everything seems to be working correctly until I try and retrieve the information from the hash. Here is the code that builds the hash.
@version_numbers.each do |version|
user_variables = Spreadsheet.open "#{version}.xls" #Opens excel sheet for all versions present
user_variables_sheet = user_variables.worksheet 0 #Loads worksheet
user_variables_hash = {}
user_variables_sheet.each 1 do |row| #Skips the first row containing titles
part_number = row[0].to_i
serial = row[1].to_i
(user_variables_hash[version] ||= []) << [part_number, serial]
end
end
When I try to retrieve the information from a 01-2 version using user_variables_hash['01-2'][0][0], it produces an error that states undefined method '[]' for nil: NilClass (NoMethodError). Any help would be greatly appreciated.
Thanks