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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:59:33+00:00 2026-05-26T19:59:33+00:00

I am working on a program that will eventually compare two .csv files and

  • 0

I am working on a program that will eventually compare two .csv files and print out any variances between the two. However, at the moment I can’t get past a “can’t convert nil into String (TypeError)” when reading one of the files.

Here is a sample line from the problematic csv file:

11/13/15,11:31:00,ABCD,4000150097,1321126281700ABCDEF,WR00002440,,,4001,1392,AI,INTERNAL RETURN,INBOUND,,ABCDEF

And here is my code so far:

require 'csv'
class CSVReportCompare

  def initialize(filename_data, filename_compare)
    puts "setting filename_data=", filename_data
    puts "setting compare=", filename_compare
    @filename_data = filename_data
    @filenam_compare = filename_compare
  end

  def printData
    @data = CSV.read(@filename_data)
    puts @data.inspect
  end

  def printCompareData
    @compareData = CSV.read(@filename_compare)
    puts @compareData.inspect
  end

  def compareData

  end

end

c1 = CSVReportCompare.new("data.csv", "compare_data.csv")
c1.printData
c1.printCompareData

Anyways, is there a way to get around the error?

  • 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-05-26T19:59:33+00:00Added an answer on May 26, 2026 at 7:59 pm

    You have a typo in your initialize method:

    @filenam_compare = filename_compare
    #-------^ missing "e"
    

    So you’re setting the wrong instance variable. Instance variables are created when they’re first used and initialized to nil so later, when you try to access @filename_compare, the instance variable with the correct name is created and has a value of nil.

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

Sidebar

Related Questions

I am working on a program that will compare two .csv files. After extracting
I'm working on a program that will sort files based on extension I currently
I'm working on a python program that will automatically combine sets of files based
I'm working on a program that will tell what level a programmer is at
I'm working on a program that will need to delete a folder (and then
I am working on a background program that will be running for a long
I'm working on a Google App Engine program that will require some basic spell
Am working on a program that will allow a graph of nodes to be
I'm working on a program that will go to a website, and then copy
I'm working a program that will have a bunch of threads processing data. Each

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.