Hi, I have a problme with fasterCSV, it isn''t rendering columns... I don''t understand why. All my columns are inside the first column the csv file :( csv_string = FasterCSV.generate(:col_sep => "\t") do |csv| # header row csv << ["id", "Email", "Ville", "Type", "Fréquence"] # data rows alerts.each do |alert| csv << [alert.id, alert.email, alert.city, alert.frequence] end end Rendering: data = Alert.export_to_csv send_data data, :type => ''text/csv; charset=utf-8; header=present'', :disposition => "attachment; filename=alerts_#{params[:export_kind]}.csv" Greg -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 27 November 2010 14:10, Greg Ma <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, > > I have a problme with fasterCSV, it isn''t rendering columns... I don''t > understand why. All my columns are inside the first column the csv file > :( > > csv_string = FasterCSV.generate(:col_sep => "\t") do |csv| > # header row > csv << ["id", "Email", "Ville", "Type", "Fréquence"] > # data rows > alerts.each do |alert| > csv << [alert.id, alert.email, alert.city, alert.frequence] > end > endHave you used ruby-debug or similar method to break into here to see whether csv_string is setup correctly? Colin> > > Rendering: > data = Alert.export_to_csv > send_data data, > :type => ''text/csv; charset=utf-8; header=present'', > :disposition => "attachment; > filename=alerts_#{params[:export_kind]}.csv" > > > Greg > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote in post #964287:> On 27 November 2010 14:10, Greg Ma <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> alerts.each do |alert| >> csv << [alert.id, alert.email, alert.city, alert.frequence] >> end >> end > > Have you used ruby-debug or similar method to break into here to see > whether csv_string is setup correctly? > > Colinyes it looks correct -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 27 November 2010 14:56, Greg Ma <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #964287: >> On 27 November 2010 14:10, Greg Ma <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> alerts.each do |alert| >>> csv << [alert.id, alert.email, alert.city, alert.frequence] >>> end >>> end >> >> Have you used ruby-debug or similar method to break into here to see >> whether csv_string is setup correctly? >> >> Colin > > yes it looks correctSo you have no problem with FasterCSV then. What exactly _is_ the problem? Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote in post #964301:> On 27 November 2010 14:56, Greg Ma <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> Colin >> >> yes it looks correct > > So you have no problem with FasterCSV then. What exactly _is_ the > problem? > > ColinThe problem is the rendering in the CSV. I a supposed to have 4 columns, but instead I have only one with all the data -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 27 November 2010 16:00, Greg Ma <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #964301: >> On 27 November 2010 14:56, Greg Ma <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>> Colin >>> >>> yes it looks correct >> >> So you have no problem with FasterCSV then. What exactly _is_ the >> problem? >> >> Colin > > The problem is the rendering in the CSV. I a supposed to have 4 columns, > but instead I have only one with all the dataYou showed some code earlier for rendering but I did not see where it is using csv_string. Can you clarify what you are doing with the string? Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.