Hello Friends I want to generate tab-delimited text file of my every users information in once. i have a button called EXPORT on my page when i clicked on this button than i want to generate tab-delimited text file for every users information. can anybody give any snippet of code or any idea for this Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''m not sure why you''d want to provide this functionality but here''s a stab at it (I''m sure someone will come up with something more elegant) File.open(''file.txt'', ''a+'') { |f| User.find(:all).each { |u| f.write("#{u.login}\t#{u.email}\n") } } On May 25, 8:37 am, Djdon Djdon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello Friends > I want to generate tab-delimited text file of my every users > information in once. > i have a button called EXPORT on my page when i clicked on this button > than i want to generate tab-delimited text file for every users > information. > can anybody give any snippet of code or any idea for this > > Thanks > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Djdon Djdon wrote:> Hello Friends > I want to generate tab-delimited text file of my every users > information in once. > i have a button called EXPORT on my page when i clicked on this button > than i want to generate tab-delimited text file for every users > information. > can anybody give any snippet of code or any idea for thisInstall fastercsv gem. Then in your code: require ''fastercsv'' FasterCSV.generate(:col_sep => "\t") {|csv| csv << [user_name, last_login, etc.]} --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Apparently Analagous Threads
- Chi Square with two tab-delimited text files
- Reading in tab (and space) delimited data within a script XXXX
- Remove carriage return in writing tab-delimited file.
- What else do tab-delimited and csv do differently?
- Why a multi column, tab delimited file has only one column after reading in with read.table specification sep="\t"