Created
September 10, 2018 13:28
-
-
Save hadisfr/d7fe42754ef51745fe3774af02f3346c to your computer and use it in GitHub Desktop.
get a csv spreadsheet from Firefox json-exported bookmarks
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
#!/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