Skip to content

Commit

Permalink
Print CLI output as JSON instead of Python dict.
Browse files Browse the repository at this point in the history
  • Loading branch information
hkeeler committed Oct 17, 2023
1 parent 58873bc commit b732419
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions regtech_data_validator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Run from the terminal to see the generated output.
"""

import pprint
import json
import sys

import pandas as pd
Expand All @@ -17,18 +17,21 @@ def csv_to_df(path: str) -> pd.DataFrame:
return pd.read_csv(path, dtype=str, na_filter=False)


def run_validation_on_df(df: pd.DataFrame, lei: str) -> None:
def run_validation_on_df(df: pd.DataFrame, lei: str|None) -> None:
"""
Run validation on the supplied dataframe and print a report to
the terminal.
"""

pprint.pprint(validate_phases(df, lei))
validation_dict = validate_phases(df, lei)
validation_json = json.dumps(validation_dict, indent=4)

print(validation_json)

if __name__ == "__main__":

def main():
csv_path = None
lei: str = None
lei: str|None = None
if len(sys.argv) == 1:
raise ValueError("csv_path arg not provided")
elif len(sys.argv) == 2:
Expand All @@ -41,3 +44,6 @@ def run_validation_on_df(df: pd.DataFrame, lei: str) -> None:

df = csv_to_df(csv_path)
run_validation_on_df(df, lei)

if __name__ == "__main__":
main()

0 comments on commit b732419

Please sign in to comment.