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 7744867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:52:18+00:00 2026-06-01T09:52:18+00:00

I am getting this error when I run the following code: #!/usr/bin/env ruby -rubygems

  • 0

I am getting this error when I run the following code:

#!/usr/bin/env ruby -rubygems
require File.join(File.dirname(__FILE__), 'authentication')
require "csv" # faster_csv (ruby 1.9)

lines = CSV.read(File.join(File.dirname(__FILE__), 'karaoke.csv')) # Exported an Excel file as CSV
lines.slice!(0) # remove header line
collection = StorageRoom::Collection.find('collection ID')
Song = collection.entry_class
lines.each do |row|
  karaoke = Song.new(:artist => row[0], :song => row[1], :genre => row[2], :file => StorageRoom::File.new_with_filename("#{karaoke.artist}#{karaoke.song}.mov"))
  if karaoke.save
    puts "Misuero Karaoke Latino saved: #{karaoke.artist}, #{karaoke.song}, #{karaoke.genre}"
  else
    puts "Misuero Karaoke Latino could not be saved: #{karaoke.errors.join(', ')}"
  end
end

And the error is:

import_csv.rb:15:in `block in <main>': undefined method `artist' for nil:NilClass (NoMethodError)
    from import_csv.rb:14:in `each'
    from import_csv.rb:14:in `<main>'

I’m interested in learning why this error occurred as well as the solution. Thanks in advance!

  • 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-01T09:52:19+00:00Added an answer on June 1, 2026 at 9:52 am

    Look at line 15 (import_csv.rb:15 tells you where to search for the issue):

    karaoke = Song.new(:artist => row[0], :song => row[1], :genre => row[2], 
      :file => StorageRoom::File.new_with_filename("#{karaoke.artist}#{karaoke.song}.mov"))
    

    In the right part of assignment expression you use karaoke.artist and karaoke.song to construct :file part of your Song, but karaoke variable is uninitialized yet (it appears on the left). In fact ruby interpreter defined karaoke variable when it saw the assignment operator and started evaluation of right-hand part of assignment expression (to initialize variable) and failed, because defined variable has nil value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I run the following code, I keep getting this error: Traceback (most recent
When I run the following code I'm getting an error that reads fig_match:rb:5:in '':
I am getting a Segmentation fault (core dumped) run-time error with the following code:
I keep getting this error when I run my web app (asp.net mvc) in
A buddy of mine has been getting this error mesage when trying to run
I am getting this run time error when using IID_IWebBrowser2 interface of CLSID_InternetExplorer. Run-Time
I am getting an error when I run this query because the data type
I'm getting a strange syntax error when I run this in VB: SQLString =
This is the actual error message i'm getting if i run it on an
I am getting undefined method `member' error in my following code Pls tell where

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.