Skip to content

Instantly share code, notes, and snippets.

@spilth
Created April 15, 2014 00:53
Show Gist options
  • Save spilth/10693366 to your computer and use it in GitHub Desktop.
Save spilth/10693366 to your computer and use it in GitHub Desktop.
Playing with InfluxDB and my Twitter data
require 'date'
require 'CSV'
require 'influxdb'
influxdb = InfluxDB::Client.new "twitter"
influxdb.delete_database("twitter")
influxdb.create_database("twitter")
CSV.foreach("data/tweets.csv", {headers: true}) do |row|
data = {
time: Date.strptime(row[3]).to_time.to_i,
value: 1
}
influxdb.write_point("tweet", data)
end
# select sum(value) from tweet group by time(1d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment