Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rev fr rules #32

Merged
merged 15 commits into from
Feb 21, 2024
Prev Previous commit
Next Next commit
Create agency_fr_rules_by_presidential_year.py
  • Loading branch information
mfebrizio committed Feb 17, 2024
commit 12045f810be5c73bf387c4bafd342e29b4a6962c
38 changes: 38 additions & 0 deletions data/fr_rules/code/agency_fr_rules_by_presidential_year.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from datetime import date
import json
from datetime import date
from pathlib import Path

#from pandas import DataFrame, to_datetime, concat
#from numpy import array

from fr_toolbelt.preprocessing import process_documents

# set file paths
p = Path(__file__)
MAIN_DIR = p.parents[1] # main folder for Reg Stats chart; store output data here
API_DIR = p.parents[1].joinpath("_api") # folder for storing retrieved API data
FINAL_YEAR = date.today().year - 1

FILES = [
f"documents_endpoint_RULE_1995_{FINAL_YEAR}.json",
f"documents_endpoint_PRORULE_1995_{FINAL_YEAR}.json",
]


def read_json(path, file):
with open(path / file, "r", encoding="utf-8") as f:
documents = json.load(f)
try:
return documents.get("results")
except AttributeError:
return documents


def process_rules(documents):
results = process_documents(documents)
return results


if __name__ == "__main__":
pass