Skip to content

Instantly share code, notes, and snippets.

@xaviershay
Created February 9, 2010 09:30
Show Gist options
  • Select an option

  • Save xaviershay/299048 to your computer and use it in GitHub Desktop.

Select an option

Save xaviershay/299048 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'hpricot'
require 'fastercsv'
doc = Hpricot::XML(File.read(ARGV[0]))
csv = FasterCSV.generate do |csv|
(doc/:Trackpoint).each do |x|
next unless x.at('HeartRateBpm') && x.at('Position')
csv << [
x.at('Time').innerText,
x.at('Position').at('LatitudeDegrees').innerText,
x.at('Position').at('LongitudeDegrees').innerText,
x.at('HeartRateBpm').at('Value').innerText,
x.at('DistanceMeters').innerText,
x.at('AltitudeMeters').innerText,
]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment