do something like this

Student.all(:order => 'name').in_groups_of(50, false).each_with_index  
do |group,index|
   export_to_csv("file_number#{index}.csv", group)
end

see 
http://stackoverflow.com/questions/1360682/rails-csvexport-to-csv-loop/1361155#1361155
 
  for more info regarding the exact same question

Adam


On 2/09/2009, at 5:05 PM, Nirmal Pn wrote:

>
> in Export to CSV, i have overall 2500 records, and while exporting it
> takes long time to export all records, so, i have decided to export in
> the form of  1st 50 students,and, 2nd 50 students,so on.  I have tried
> the below code. but it could able to fetch only 1st 50 students.
>
> please, guide me how to solve the problem
>
>
> @student_count = Student.find(:all)
>      @count1 = @student_count.count
>      st_per_file = 50
>      count = 0
>      unless @count1==count
>      students = Student.find(:all, :order => 'name', :limit =>
> st_per_file, :offset => (st_per_file*count))
>      count = count + 1
>      end
> -- 
> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to