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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:42:05+00:00 2026-05-13T15:42:05+00:00

i have a code that works fine with ruby 1.87 but dont works with

  • 0

i have a code that works fine with ruby 1.87 but dont works with ruby 1.9. It says that CSV::Writer is undeclared but it still part of the rdoc. Does the csv api changed, after the fastercsv merge, or not?

my code:

require 'csv'

def self.export_csv
 file_name = File.join(RAILS_ROOT, 'public','csv',"#{start_date_f}_#{end_date_f}.csv")
 return file_name if File.exist?(file_name)
 @results = find(:all)
 header_row = []
 outfile = File.open(file_name, 'wb')
 CSV::Writer.generate(outfile) do |csv|
      header_row = ['gateway_id','created', 'gateway_status_id', 'panel_id',  'panel_status','volts_out', 'amps_out', 'temp','aid' ,'sid', 'pisid']
      csv << header_row
  end
end

The error that i receive: NameError: uninitialized constant CSV::Writer

Note that require ‘csv’ is there. i try it in my console, when i do the require ‘csv’, it works, but as soon as i call CSV::Writer i receive that error.
This code works fine with ruby 1.87, so it makes me think that it is a ruby 1.9 csv problem since it was merged with fasterCSV.

  • 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-13T15:42:05+00:00Added an answer on May 13, 2026 at 3:42 pm

    The csv library is still there, but CSV::Writer is not. According to the csv.rb in 1.9.0:

    # I'm sure I'll miss something, but I'll try to mention most of the major
    # differences I am aware of, to help others quickly get up to speed:
    #
    # === CSV Parsing
    #
    # * This parser is m17n aware.  See CSV for full details.
    # * This library has a stricter parser and will throw MalformedCSVErrors on
    #   problematic data.
    # * This library has a less liberal idea of a line ending than CSV.  What you
    #   set as the <tt>:row_sep</tt> is law.  It can auto-detect your line endings
    #   though.
    # * The old library returned empty lines as <tt>[nil]</tt>.  This library calls
    #   them <tt>[]</tt>.
    # * This library has a much faster parser.
    #
    # === Interface
    #
    # * CSV now uses Hash-style parameters to set options.
    # * CSV no longer has generate_row() or parse_row().
    # * The old CSV's Reader and Writer classes have been dropped.
    # * CSV::open() is now more like Ruby's open().
    # * CSV objects now support most standard IO methods.
    # * CSV now has a new() method used to wrap objects like String and IO for
    #   reading and writing.
    # * CSV::generate() is different from the old method.
    # * CSV no longer supports partial reads.  It works line-by-line.
    # * CSV no longer allows the instance methods to override the separators for
    #   performance reasons.  They must be set in the constructor.
    

    A little later on, there’s an example of how to write line-by-line (as well as other methods of writing):

    # === To a File
    #
    #   CSV.open("path/to/file.csv", "wb") do |csv|
    #     csv << ["row", "of", "CSV", "data"]
    #     csv << ["another", "row"]
    #     # ...
    #   end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a java script code that works fine when run through a browser,
I have code that looks like the following, which works fine for displaying the
I have a website that is perfectely centered aligned. The CSS code works fine.
I am querying information from Active Directory . I have code that works, but
I have some Python code that works correctly when I use python.exe to run
I have a block of code that works and I wanted to ask what
I have to work on some code that's using generic lists to store a
Sometimes I have to work on code that moves the computer clock forward. In
I have code that references a web service, and I'd like the address of
I have code that looks like: //System.Data.IDataRecord dr try { Consolidated = Utility.NullConvert.ToBool(dr[Constants.Data.Columns.cConsolidated], false);

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.