Skip to content

Instantly share code, notes, and snippets.

@stevej
Created October 8, 2008 21:29
Show Gist options
  • Save stevej/15603 to your computer and use it in GitHub Desktop.
Save stevej/15603 to your computer and use it in GitHub Desktop.
For a big file filled with atom entries, spit out the epoch of each atom entry's updated timestamp. Output to stdout. so pipe it to your file.
#!/usr/bin/ruby
# usage: ./atom_timeseries.rb file
# For a big file filled with atom entries, spit out
# the epoch of each atom entry's updated timestamp.
# Output to stdout. so pipe it to your file.
require 'Time'
file = File.new(ARGV[0], "r")
while (line = file.gets)
if line =~ /<updated>(.*)<\/updated>/
puts Time.parse((/<updated>(.*)<\/updated>/.match(line))[1]).to_i
end
end
file.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment