Skip to content

Commit

Permalink
🐛 update check_manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
HuangXiaoyan0106 committed Jan 10, 2024
1 parent db36acb commit e8e7f85
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions d3b_dff_cli/modules/validation/check_manifest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import pandas as pd
import argparse
import csv

# Define a function to perform validation
def validate_row(row, rules):
Expand Down Expand Up @@ -60,13 +61,18 @@ def validate_row(row, rules):
def main(args):
rule_type = args.rule_type
rules_json = args.rules
manifest_data = pd.read_csv(args.manifest_file)
manifest_data = []
with open(args.manifest_file, "r") as csv_file:
csv_reader = csv.DictReader(csv_file)
for row in csv_reader:
manifest_data.append(row)

with open(rules_json, "r") as json_file:
validation_rules = json.load(json_file)[rule_type]

# Iterate through each row in the DataFrame and perform validation
validation_failed = False
for index, row in manifest_data.iterrows():
for index, row in enumerate(manifest_data):
is_valid, messages = validate_row(row, validation_rules)
if not is_valid:
error_message = "Validation Failed For Row {0}:\n{1}".format(index + 1, '\n'.join(messages))
Expand Down

0 comments on commit e8e7f85

Please sign in to comment.