Skip to content

Instantly share code, notes, and snippets.

@arsalanses
Created November 12, 2022 10:46
Show Gist options
  • Save arsalanses/805d6e7189e9f1e390a2d2d84c72b9d2 to your computer and use it in GitHub Desktop.
Save arsalanses/805d6e7189e9f1e390a2d2d84c72b9d2 to your computer and use it in GitHub Desktop.
import json
import csv
import os
EXCLUDE_FILES = ["json.zip", "main.py", "results.csv"]
PATH = "/"
KEY_WORD = "go2tr"
counter = 0
with open("results.csv", 'w') as result_file:
writer = csv.writer(result_file)
writer.writerow(["counter", "fild_1", "entry.name", "index"])
with os.scandir(PATH) as entries:
for entry in entries:
if entry.name in EXCLUDE_FILES:
continue
with open(entry, 'r') as read_file:
for index, line in enumerate(read_file):
data_dict = json.loads(line)
fild_1 = data_dict["fild_1"]
if KEY_WORD in link:
counter += 1
writer.writerow([counter, fild_1, entry.name, index])
print(counter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment