Guest User

Untitled

a guest
Nov 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. let dataToWrite = '';
  2. const fs = require('fs');
  3. const testData = require('./your/takeout/file.json')
  4.  
  5. for (item in testData.locations){
  6. 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))
  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))
  8.  
  9. dataToWrite = dataToWrite + `${testData.locations[item].timestampMs},${lat},${lng}\n`
  10. }
  11.  
  12. fs.writeFile('what-you-want-t0-call-it.csv', dataToWrite, 'utf8', function (err) {
  13. if (err) {
  14. console.log('Some error occured - file either not saved or corrupted file saved.');
  15. } else{
  16. console.log('it saved');
  17. }
  18. });
Add Comment
Please, Sign In to add comment