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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:21:11+00:00 2026-05-26T18:21:11+00:00

I have some data to export from DB and save as CSV file, and

  • 0

I have some data to export from DB and save as CSV file, and then upload to an FTP server. The site is hosted on Heroku and I understand that you can only write to the tmp (or log?) directories.

This works great on my local machine, but does not work on Heroku.

Here’s my rake task:

require 'csv' 
require 'net/ftp'

task :export_data => :environment do
  path = "tmp/" 
  filename = 'test_' + Date.today.to_s + '.dat' 

  messages = Message.where( :foo => bar) 
  CSV.open(path + filename, "wb", :col_sep => '|') do |csv| 

    messages.each do |m| 
      csv << [m.id.to_s, m.name] 
      puts "Processing message " + m.id.to_s 
    end 
  end 

  puts "Uploading " + filename 
  ftp = Net::FTP.new('ftp.hostname.com') 
  ftp.login(user = "******", passwd = "*******") 
  ftp.puttextfile(path + filename, filename) 
  ftp.quit() 

  puts "Finished." 
end

There are 2 issues:

Q1. It is incredibly slow to iterate through the records. 5 minutes for 200. I don’t know if this will be usable.

Q2. The ftp has an error and crashes. It starts to put the file on the FTP server, but does not write any data to it. It is an empty file. The log reads:

Starting process with command `rake jobs:work`
2011-10-17T21:17:11+00:00 app[worker.1]: (in /app)
2011-10-17T21:17:13+00:00 heroku[worker.1]: State changed from starting to up
2011-10-17T21:17:13+00:00 app[worker.1]: rake aborted!
2011-10-17T21:17:13+00:00 app[worker.1]: Don't know how to build task 'jobs:work'
2011-10-17T21:17:13+00:00 app[worker.1]: /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1720:in `[]'
2011-10-17T21:17:13+00:00 app[worker.1]: /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2040:in `invoke_task'
2011-10-17T21:17:13+00:00 app[worker.1]: /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2019:in `block (2 levels) in top_level'
2011-10-17T21:17:13+00:00 app[worker.1]: /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2019:in `each'
2011-10-17T21:17:13+00:00 app[worker.1]: /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2019:in `block in top_level'
2011-10-17T21:17:13+00:00 app[worker.1]: /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
2011-10-17T21:17:13+00:00 app[worker.1]: /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2013:in `top_level'
2011-10-17T21:17:13+00:00 app[worker.1]: /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1992:in `run'
2011-10-17T21:17:13+00:00 app[worker.1]: /usr/ruby1.9.2/bin/rake:31:in `<main>'
2011-10-17T21:17:13+00:00 heroku[worker.1]: Process exited
2011-10-17T21:17:14+00:00 heroku[worker.1]: State changed from up to crashed

Is there is an issue with the file not being available or some other issue with the file system? Works on local machine.

Any ideas?

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-26T18:21:11+00:00Added an answer on May 26, 2026 at 6:21 pm

    Answers:

    Q1: It’s not slow. It only looks slow because the slow part is outputting to the console.

    Q2: FTP was fixed by setting ftp.passive = true

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script to export data from MYSQL to a CSV file. the
I'm trying to export data from SQL Server into CSV format. I have a
I have a requirement to export some data from a table (not all fields
I have almost 100MB of example.sql file. (Actually data export file from another database)
I have an Excel table with some data that I would like to export
I have a rails app with some nested data that I'd like to export
I have a CSV export script (enrdata_arch.php) which calls information from an existing database
I want to export some data from my jruby on rails webapp to excel,
I want to export data from a table to a specifically formatted XML file.
I have a program who's generating some data in registry. I save it with

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.