organization-logos / prune-dataset.py
tzvc's picture
collect + pruned
3b53130
raw
history blame contribute delete
No virus
774 Bytes
import json
import os
def file_exists(file_path):
return os.path.isfile(file_path)
def read_jsonl(file_path):
data = []
with open(file_path, 'r') as f:
for line in f:
data.append(json.loads(line))
return data
if __name__ == "__main__":
count = 0
data = read_jsonl("./data/metadata.jsonl")
print(len(data))
for d in data:
# check if file exist
if not file_exists("./data/" + d.get("file_name")):
print("File not found: " + d.get("file_name"))
continue
# write to new JSONL file
with open("./data/metadata-pruned.jsonl", "a") as f:
f.write(json.dumps(d) + "\n")
count +=1
# print(d.get("file_name"))
print(len(data))
print(count)