如何从我的Heroku控制台导出Ruby数组到CSV? [英] How to export a Ruby Array from my Heroku console into CSV?

查看:165
本文介绍了如何从我的Heroku控制台导出Ruby数组到CSV?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的heroku控制台导出一个数组到一个本地CSV文件。

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

在我目前的情况下,我有一个每日rake任务,寻找tweets谈论我的应用程序。我想分析这些推文,看看他们什么时候进来等:

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

任何

推荐答案

您不能从heroku控制台访问本地文件系统。一个选项是使用 Tee 。 Tee将输出发送到STDOUT和文件,因此您可以对打印的所有内容进行本地日志。

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

这篇关于如何从我的Heroku控制台导出Ruby数组到CSV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆