-
-
Save jalbertbowden/c0d1373a2bd23bd960a4c1110347695b to your computer and use it in GitHub Desktop.
Python script to split starred.json into smaller junks to make them usable for alternatives. Sometimes trying to import starred.json files with more than 50mb or even less fail. -> split it and it should work.
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
# run script within a directory where your exported starred.json file is available | |
import json | |
from copy import deepcopy | |
json_data = open('starred.json') | |
data = json.load(json_data) | |
default = deepcopy(data) | |
default['items'] = [] | |
l = len(data['items']) | |
ran = range(l) | |
steps = ran[1000::1000] | |
data_split = deepcopy(default) | |
count = 0 | |
for i in ran: | |
data_split['items'].append(data['items'][i]) | |
if i in steps or i == l-1: | |
name = 'starred_split_' + str(count) + '.json' | |
with open(name, 'w') as outfile: | |
json.dump(data_split, outfile) | |
data_split = deepcopy(default) | |
count = count + 1 | |
print 'now you can import your splitted files into your new reader. One by one.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment