import json
from tqdm import tqdm

#Read JSON data into the datastore variable
with open("20181017.json", 'r') as f:
    read_data = json.load(f)

write_data = []
count = 0

probes = read_data["objects"]

for probe in tqdm(probes):
        
    if probe["address_v4"] is not None and probe["longitude"] is not None and probe["latitude"] is not None:
        #tqdm.write(str(probe))
        count += 1
        write_data.append(probe)

print("\n there is %i valid probes" % count)
with open("probes.json", 'w') as f:
    json.dump(write_data, f)