-
-
Save Dan-Q/311b032948189bf297da33e00dd62cc1 to your computer and use it in GitHub Desktop.
Split GPX files generated by GPSBabel based on Google Takeout "My Location" KML into multiple months
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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