Last active
December 19, 2015 13:40
-
-
Save tamouse/5964037 to your computer and use it in GitHub Desktop.
running csv output through popen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ irb -r open3 -r csv | |
2.0.0-p247 :001 > Open3.popen2e("cat > blah") do |i,oe,t| | |
2.0.0-p247 :002 > csv = CSV.new(i) | |
2.0.0-p247 :003?> csv << [1,2,3,4] | |
2.0.0-p247 :004?> csv.close | |
2.0.0-p247 :005?> end | |
=> nil | |
2.0.0-p247 :006 > quit | |
tamara@pontiki:~/Dropbox/Public/Examples:2013-07-10@12:00:08 | |
$ file blah | |
blah: ASCII text | |
tamara@pontiki:~/Dropbox/Public/Examples:2013-07-10@12:00:12 | |
$ more blah | |
1,2,3,4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2.0.0-p247 :001 > Open3.popen2e("cat > blah") do |i,oe,t| | |
2.0.0-p247 :002 > CSV(i) do |csv| | |
2.0.0-p247 :003 > csv << [1,2,3,4,'five'] | |
2.0.0-p247 :004?> end | |
2.0.0-p247 :005?> end | |
=> <#CSV io_type:IO encoding:UTF-8 lineno:1 col_sep:"," row_sep:"\n" quote_char:"\""> | |
2.0.0-p247 :006 > quit | |
tamara@pontiki:~/Dropbox/Public/Examples:2013-07-10@12:15:12 | |
$ file blah | |
blah: ASCII text | |
tamara@pontiki:~/Dropbox/Public/Examples:2013-07-10@12:15:17 | |
$ cat blah | |
1,2,3,4,five |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment