Hello,
What are examples of reading a csv file (Comma) into an Array
Hello,
What are examples of reading a csv file (Comma) into an Array
On Nov 13, 6:58 pm, Brian S. [email protected] wrote:
What are examples of reading a csv file (Comma) into an Array
On the Internet.
On Nov 14, 9:05 am, Phrogz [email protected] wrote:
On Nov 13, 6:58 pm, Brian S. [email protected] wrote:
What are examples of reading a csv file (Comma) into an Array
On the Internet.
May be the following code will help you:
def member_data
member = Member.find(:all)
stream_csv do |csv|
csv << [“First Name”,“Last Name”,“Email”]
member.each do |u|
csv << [u.first_name,u.last_name,u.email]
end
end
end
Explanation: Member is the model name. First name, last name and email
are the fields shown while downloading CSV.
Following code to be written in rhtml file:
<%= link_to ‘download’, :controller => ‘reports’, :action =>
‘member_data’ %>
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs