Skip to content

Commit

Permalink
Merge branch 'redcap2reproschema' of https://github.com/yibeichan/rep…
Browse files Browse the repository at this point in the history
…roschema-py into redcap2reproschema
  • Loading branch information
yibeichan committed Dec 28, 2023
2 parents ad7191a + 8838e06 commit 163316c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions reproschema/redcap2reproschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def process_csv(
os.makedirs(f"{abs_folder_path}/protocols/{protocol_name}", exist_ok=True)
return datas, order, languages


def redcap2reproschema(csv_file, yaml_file, schema_context_url=None):
"""
Convert a REDCap data dictionary to Reproschema format.
Expand All @@ -354,7 +355,7 @@ def redcap2reproschema(csv_file, yaml_file, schema_context_url=None):

# Read the YAML configuration
with open(yaml_file, "r") as f:
protocol = yaml.safe_load(f)
protocol = yaml.safe_load(f)

protocol_name = protocol.get("protocol_name")
protocol_display_name = protocol.get("protocol_display_name")
Expand All @@ -363,7 +364,7 @@ def redcap2reproschema(csv_file, yaml_file, schema_context_url=None):
if not protocol_name:
raise ValueError("Protocol name not specified in the YAML file.")

protocol_name = protocol_name.replace(' ', '_') # Replacing spaces with underscores
protocol_name = protocol_name.replace(" ", "_") # Replacing spaces with underscores

# Check if the directory already exists
if not os.path.exists(protocol_name):
Expand Down Expand Up @@ -478,6 +479,7 @@ def redcap2reproschema(csv_file, yaml_file, schema_context_url=None):
protocol_visibility_obj,
)


def main():
parser = argparse.ArgumentParser(
description="Convert REDCap data dictionary to Reproschema format."
Expand All @@ -489,5 +491,6 @@ def main():
# Call the main conversion function
redcap2reproschema(args.csv_file, args.yaml_file)


if __name__ == "__main__":
main()

0 comments on commit 163316c

Please sign in to comment.