Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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 application. I'd like to analyse those tweets to see at what time they came in, etc:

heroku run console tweets = Tweet.all code to export tweets into a local CSV file goes here 

Any ideas would be greatly appreciated!

like image 678
Carl Sednaoui Avatar asked May 27 '12 13:05

Carl Sednaoui


2 Answers

You can't access your local filesystem from the heroku console. One option is to use Tee. Tee sends the output to both STDOUT and a file, so you can have a local log of everything that was printed.

heroku run console | tee output.txt 
like image 187
spike Avatar answered Sep 22 '22 09:09

spike


I tried using Tee as suggested and also got stuck at

Running `console` attached to terminal... up, run.4165 

I ended up running an SSH shell to localhost and then piped it through tee.

$ ssh localhost | tee output.txt $ heroku run console 

Might not be the best solution, but it worked for me.

like image 42
Rome Portlock Avatar answered Sep 18 '22 09:09

Rome Portlock