Skip to content

Instantly share code, notes, and snippets.

@WanderingHogan
Created November 22, 2017 17:34
Show Gist options
  • Select an option

  • Save WanderingHogan/90093d01bf449ae4daf419d850ec9ee1 to your computer and use it in GitHub Desktop.

Select an option

Save WanderingHogan/90093d01bf449ae4daf419d850ec9ee1 to your computer and use it in GitHub Desktop.
let dataToWrite = '';
const fs = require('fs');
const testData = require('./your/takeout/file.json')
for (item in testData.locations){
let lat = String(testData.locations[item].latitudeE7).substr(0, (String(testData.locations[item].latitudeE7).length - 7)) + '.' + String(testData.locations[item].latitudeE7).substr((String(testData.locations[item].latitudeE7).length - 7))
let lng = String(testData.locations[item].longitudeE7).substr(0, (String(testData.locations[item].longitudeE7).length - 7)) + '.' + String(testData.locations[item].longitudeE7).substr((String(testData.locations[item].longitudeE7).length - 7))
dataToWrite = dataToWrite + `${testData.locations[item].timestampMs},${lat},${lng}\n`
}
fs.writeFile('what-you-want-t0-call-it.csv', dataToWrite, 'utf8', function (err) {
if (err) {
console.log('Some error occured - file either not saved or corrupted file saved.');
} else{
console.log('it saved');
}
});
@WanderingHogan
Copy link
Author

this converts the takeout json file into a CSV file you can load in your GIS software and plot the lat/lng with timestamp.

A lot of other cool data is stripped out. resulting CSV is way smaller than the huge json file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment