Last active
June 2, 2017 22:35
-
-
Save huberf/949374d23a49bfe24d94da787d138eb1 to your computer and use it in GitHub Desktop.
Nomie Backup Duplicate Clearing
This file contains hidden or 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
# Clear duplicates from Dropbox backup | |
import json | |
file = open('Android-Nexus 5X-559865688.nomie.json') | |
dataRaw = file.read() | |
data = json.loads(dataRaw) | |
events = data['events'] | |
cleanedEvents = [] | |
lastId = '' | |
for i in events: | |
if not i['_id'] == lastId: | |
cleanedEvents += [i] | |
lastId = i['_id'] | |
beforeClearCount = len(data['events']) | |
data['events'] = cleanedEvents | |
afterClearCount = len(data['events']) | |
print('Count before clear: ', beforeClearCount) | |
print('Count after clear: ', afterClearCount) | |
output = open('Android-Nexus 5X-1.nomie.json', 'w') | |
output.write(json.dumps(data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment