Skip to content

Instantly share code, notes, and snippets.

@Dan-Q

Dan-Q/split-takeout-gpx.rb Secret

Created Sep 4, 2020
Embed
What would you like to do?
Split GPX files generated by GPSBabel based on Google Takeout "My Location" KML into multiple months
INPUT = "Google Maps Location History.gpx"
OUTPUT_PREFIX = "Result"
START_YEAR = 2013
(START_YEAR..Time.now.year).each do |year|
(1..12).each do |month|
long_month = sprintf('%02d', month)
puts filename = "#{OUTPUT_PREFIX} #{year}-#{long_month}.gpx"
`head -n5 "#{INPUT}" > "#{filename}"`
`grep -B2 -A1 "<time>#{year}-#{long_month}" "#{INPUT}" >> "#{filename}"`
`tail -n3 "#{INPUT}" >> "#{filename}"`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.