Skip to content

Instantly share code, notes, and snippets.

@ioquatix
Created June 21, 2019 04:55
Show Gist options
  • Save ioquatix/b46a5c6b215e4db7b2b31b18d9f43084 to your computer and use it in GitHub Desktop.
Save ioquatix/b46a5c6b215e4db7b2b31b18d9f43084 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'csv'
require 'logger'
logger = Logger.new($stdout)
CSV do |csv|
5.times do
logger.info "Generating row..."
csv << ['1', '2', '3']
end
end
@ioquatix
Copy link
Author

If you run this:

rows.rb > output.csv

output.csv contains the following:

I, [2019-06-21T16:54:42.813759 #79664]  INFO -- : Generating row...
1,2,3
I, [2019-06-21T16:54:42.813883 #79664]  INFO -- : Generating row...
1,2,3
I, [2019-06-21T16:54:42.813902 #79664]  INFO -- : Generating row...
1,2,3
I, [2019-06-21T16:54:42.813915 #79664]  INFO -- : Generating row...
1,2,3
I, [2019-06-21T16:54:42.813927 #79664]  INFO -- : Generating row...
1,2,3

Is that what you wanted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment