-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_matching.py
42 lines (37 loc) · 1.35 KB
/
test_matching.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import csv
import glob
import argparse
import header_mapping as hm
from header_mapping import HeaderMapping
from operators.utils import load_geojson
from validator import CSVValidator
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--dir")
args = parser.parse_args()
if args.dir is not None:
dirpath = args.dir
else:
dirpath = "data"
hos_csvs = glob.glob(os.path.join(dirpath, "HOS*.csv"))
print(f"validating {len(hos_csvs)} HOS file(s)")
hos_validator = CSVValidator("HOS")
for hos in hos_csvs:
result = hos_validator.validate_csv(hos)
if result['pass']:
print(os.path.basename(hos), "pass: True")
else:
print(os.path.basename(hos), "pass: False")
print(f"header errors: {len(result['header_errors'])}")
for error in result['header_errors']:
print(f"'{error}'")
# print(f"location errors: {len(result['location_errors'])}")
# for error in result['location_errors']:
# print(f"'{error}'")
# print(result)
# ltc_csvs = glob.glob(os.path.join(dirpath, "LTC*.csv"))
# print(f"validating {len(ltc_csvs)} LTC file(s)")
# ltc_validator = CSVValidator("LTC")
# for ltc in ltc_csvs:
# result = ltc_validator.validate_csv(ltc)