Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'csv'
require 'time'
drunk_tweets = []
CSV.new(File.new('tweets.csv'), headers: true, header_converters: :symbol).to_a.map(&:to_hash).each do |row|
tweet_hour = Time.parse(row[:timestamp]).hour
drunk_tweets << row if tweet_hour > 22 || tweet_hour < 5
end
drunk_tweets.reverse.each {|t| puts "#{Time.parse(t[:timestamp])}: #{t[:text]} (https://twitter.com/darrinholst/status/#{t[:tweet_id]})\n---\n"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment