summaryrefslogtreecommitdiff
path: root/scripts/split_json.py
blob: a6905dbf3b65c2b0509b6288d80a3351e6a1c4e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pickle
import json
from os.path import dirname, abspath,join
try:
    with  open('crawler/items.json', "r") as json_dump:
        json_data = json.load(json_dump)
        json_dump.close()
    a = [saved_data for saved_data in json_data if str(saved_data).startswith("{u'ch")]
    with open(join(dirname(abspath(dirname(__file__))),'tbc_error_page/error.pickle'), "w+") as error_json:
        pickle.dump(a, error_json)
        error_json.close()

    b = [saved_data for saved_data in json_data if str(saved_data).startswith("{u'br")]
    with open(join(dirname(abspath(dirname(__file__))),'tbc_error_page/broken.pickle'), "w+") as broken_json:
        pickle.dump(b, broken_json)
        broken_json.close()


except ValueError:
    print("Couldn't find file")