Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8958305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:10:53+00:00 2026-06-15T15:10:53+00:00

Edit: The issue is being unable to get the quantity of arrays within the

  • 0

Edit: The issue is being unable to get the quantity of arrays within the hash, so it can be, x = amount of arrays. so it can be used as function.each_index{|x| code }

Trying to use the index of the amount of rows as a way of repeating an action X amount of times depending on how much data is pulled from a CSV file.

Terminal issued

=> Can't convert symbol to integer (TypeError)

Complete error:

=> ~/home/tests/Product.rb:30:in '[]' can't convert symbol into integer (TypeError) from ~home/tests/Product.rub:30:in 'getNumbRel'
from test.rb:36:in '<main>'

the function is that is performing the action is:

def getNumRel
  if defined? @releaseHashTable
     return @releaseHashTable[:releasename].length
  else
      @releaseHashTable = readReleaseCSV()
      return @releaseHashTable[:releasename].length
  end
end

The csv data pull is just a hash of arrays, nothing snazzy.

def readReleaseCSV()
   $log.info("Method "+"#{self.class.name}"+"."+"#{__method__}"+" has started")
   $log.debug("reading product csv file")
   # Create a Hash where the default is an empty Array
   result = Array.new
   csvPath = "#{File.dirname(__FILE__)}"+"/../../data/addingProdRelProjIterTestSuite/releaseCSVdata.csv"
   CSV.foreach(csvPath, :headers => true, :header_converters => :symbol) do |row|
     row.each do |column, value|
       if "#{column}" == "prodid"
         proHash = Hash.new { |h, k| h[k] = [ ] }
         proHash['relid'] << row[:relid]
         proHash['releasename'] << row[:releasename]
         proHash['inheritcomponents'] << row[:inheritcomponents]

         productId = Integer(value)
         if result[productId] == nil
            result[productId] = Array.new
         end

         result[productId][result[productId].length] = proHash
      end
    end
  end
  $log.info("Method "+"#{self.class.name}"+"."+"#{__method__}"+" has finished")
  @productReleaseArr = result
 end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:10:55+00:00Added an answer on June 15, 2026 at 3:10 pm

    Sorry, couldn’t resist, cleaned up your method.

    # empty brackets unnecessary, no uppercase in method names
    def read_release_csv
      # you don't need + here
      $log.info("Method #{self.class.name}.#{__method__} has started")
      $log.debug("reading product csv file")
      # you're returning this array. It is not a hash. [] is preferred over Array.new
      result = []
      csvPath = "#{File.dirname(__FILE__)}/../../data/addingProdRelProjIterTestSuite/releaseCSVdata.csv"
      CSV.foreach(csvPath, :headers => true, :header_converters => :symbol) do |row|
        row.each do |column, value|
          # to_s is preferred
          if column.to_s == "prodid"
            proHash = Hash.new { |h, k| h[k] = [ ] }
            proHash['relid'] << row[:relid]
            proHash['releasename'] << row[:releasename]
            proHash['inheritcomponents'] << row[:inheritcomponents]
            # to_i is preferred
            productId = value.to_i
            # this notation is preferred
            result[productId] ||= []
            # this is identical to what you did and more readable
            result[productId] << proHash
          end
        end
      end
      $log.info("Method #{self.class.name}.#{__method__} has finished")
      @productReleaseArr = result
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT Complicating matters it appears that there is an issue (that is being worked
If anyone can make a better title, please edit it. The issue I am
EDIT: This issue is already submitted on Github. Changing the Act part to this
EDIT: It was some issue with Notepad++'s regex engine. The regex worked fine in
EDIT : Accepted answer points out what my issue was. I added another answer
EDIT: I've found what's causing the issue, but I don't know why and I
EDIT: I am basically running into the following documented issue . I am using
Edit: closing anchor fixed. This issue exists when testing on the following browsers: Google
Edit 4/4/12 I STILL HAVE ONE QUESTION: I solved my issue but it adds
Having an interesting issue with redirects. On my user update page (at /username/edit), users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.