Skip to content

Instantly share code, notes, and snippets.

@hadisfr
Created September 10, 2018 13:28
Show Gist options
  • Save hadisfr/d7fe42754ef51745fe3774af02f3346c to your computer and use it in GitHub Desktop.
Save hadisfr/d7fe42754ef51745fe3774af02f3346c to your computer and use it in GitHub Desktop.
get a csv spreadsheet from Firefox json-exported bookmarks
#!/usr/bin/env python3
import json
import csv
def process(bookmark):
global res
if 'children' in bookmark.keys():
for child in bookmark['children']:
process(child)
elif bookmark['type'] == 'text/x-moz-place':
res.append((bookmark['title'], bookmark['uri']))
if __name__ == '__main__':
with open('bookmarks-2018-05-14.json', 'r') as f: # modify json name
bookmarks = json.load(f)
res = []
process(bookmarks)
with open('bookmarks.csv', 'w') as f:
writer = csv.writer(f)
writer.writerow(('Title', 'URI'))
for entry in res:
writer.writerow(entry)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment