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