Skip to content

Commit

Permalink
improved error catching in manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
mshadbolt committed Jun 4, 2024
1 parent 9497029 commit fef07c0
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/clinical_etl/CSVConvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,25 @@ def csv_convert(input_path, manifest_file, minify=False, index_output=False, ver
# read manifest data
print(f"{Bcolors.OKGREEN}Starting conversion...{Bcolors.ENDC}", end="")
manifest = load_manifest(manifest_file)
mappings.IDENTIFIER_FIELD = manifest["identifier"]
if mappings.IDENTIFIER_FIELD is None:
try:
mappings.IDENTIFIER_FIELD = manifest["identifier"]
if manifest["identifier"] is None:
raise TypeError
except KeyError as e:
sys.exit("Need to specify what the main identifier column name is as 'identifier' in the manifest file, "
"see README for more details.")
mappings.DATE_FORMAT = manifest["date_format"]
if mappings.DATE_FORMAT is None:
sys.exit("Need to specify what the date format is in the manifest file, "
except TypeError as e:
sys.exit("'identifier' in the manifest file cannot be blank, see README for more details.")
try:
mappings.DATE_FORMAT = manifest["date_format"]
if manifest["date_format"] is None:
raise TypeError
if sorted(manifest["date_format"]) != sorted("DMY"):
raise TypeError
except KeyError as e:
sys.exit("'date_format' in the manifest file cannot be blank, see README for more details.")
except TypeError as e:
sys.exit("Need to specify a valid value for the date format in the manifest file, "
"see README for more details.")

# read the schema (from the url specified in the manifest) and generate
Expand Down

0 comments on commit fef07c0

Please sign in to comment.