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

  • Home
  • SEARCH
  • 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 6001493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:50:33+00:00 2026-05-23T00:50:33+00:00

I am using csv to export data. I am dynamically populating the fields and

  • 0

I am using csv to export data. I am dynamically populating the fields and in order to do so i have added loop in to csv:

csv_data = CSV.generate do |csv|
  csv << [
  @userHeaders.each do |user|
    "#{user.name}"
  end
  ]
end

but this returns some thing like this: [#<User >, #<User >, #<User >, #<User >]

but when i tried to inspect the value after assigning it to a variable, it displays all the names that have been passed.

name = "#{user.name}"
puts name.inspect  # (this diaplays all the names)

is there any format to display the data while looping inside csv?

please guide with answer
thanks

  • 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-23T00:50:34+00:00Added an answer on May 23, 2026 at 12:50 am

    Try just using the map (aka collect) method of your array:

    csv_data = CSV.generate do |csv|
      csv << @userHeaders.map { |user| user.name }
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a csv export of data from mysql using the following
I currently have a sproc that is exporting data to a csv file using
I'm trying to export/import data in .csv format using SQLDeveloper. The source and destination
I have a salesforce I export to CSV using a URL like this https://tapp0.salesforce.com/00OT00000014APi?export=1&enc=UTF-8&xf=csv
Hi I'm using the following code to generate a CSV file containing data from
Is it possible to Export a MySQL to a CSV using the command line
I am using the below code to Export DataTable to MS Word,Excel,CSV format &
Exporting some data from mysql to a csv file using FasterCSV. I'd like the
I have a CSV export script (enrdata_arch.php) which calls information from an existing database
I'm using the Import/Export Wizard to import some data to a table. Total of

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.