How to export a Ruby Array from my Heroku console into CSV?

后端 未结 10 1043
悲&欢浪女
悲&欢浪女 2021-02-02 11:17

I am looking to export an array from my heroku console into a local CSV file.

In my current situation, I have a daily rake task which looks for tweets talking about my a

10条回答
  •  误落风尘
    2021-02-02 11:25

    You can also use rails runner to run a line of code or three on heroku and pipe (or tee) the results to a file:

    heroku run rails runner \'Tweet.all.to_csv\' -a my-app-name | all_tweets.csv
    

    You can disable rails logging if that's showing up in your file and trim the top of the file if you're getting startup logging like "Running `rails runner`" in your file, but that should be easy to do.

提交回复
热议问题