-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/add dataset csv file type #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
a410e14
(HP-2029) add dependencies to pyproject.toml
george42-ctds 2c3aa92
(HP-2029) add new test data file
george42-ctds 7ce019d
(HP-2029) add 'typesets' and 'sync_fields'
george42-ctds c372e8d
(HP-2029) add new fixtures to conftest
george42-ctds 033f94d
(HP-2029) include new allowed file_types
george42-ctds 9858cfa
(HP-2029) do not validate dataset input files
george42-ctds 4a97f95
(HP-2029) add new conversion logic
george42-ctds 67ab7dd
(HP-2029) add dataset conversion module
george42-ctds e0c5e13
(HP-2029) add new extract logic
george42-ctds d8b35c0
(HP-2029) add test dataset data
george42-ctds 0052caf
(HP-2029) Add file_type options to extract CLI
george42-ctds afecf4b
(HP-2029) add csv-header check to validate
george42-ctds 7c92e48
(HP-2029) add unit tests for validating dataset as dictionary
george42-ctds 77b8060
(HP-2029) swap order of fields lines
george42-ctds e3bd56a
(HP-2029) re-lock to upgrade dependencies
george42-ctds 676ee59
Merge branch 'master' into feat/add-dataset-csv-file-type
george42-ctds dbe5c76
(HP-2029) Remove some debug log messages
george42-ctds 19b2293
(HP-2029) Add row to test REDCap dictionary
george42-ctds 854b6e4
(HP-2029) Add invalid REDCap test dictionary
george42-ctds 4f1a086
(HP-2029) skip fallback to dataset for invalid REDCap dictionaries
george42-ctds ec20d00
(HP-2029): remove some debug statements
george42-ctds dfb77c2
(HP-2029) re-order imports
george42-ctds c75492c
(HP-2029) move 'test_title' variable to local fixture
george42-ctds 47cfd9f
(HP-2029) add docstrings to tests
george42-ctds 082ce27
(HP-2029) Allow numbers in constraint max/min properties
george42-ctds 4214c11
(HP-2029) Add test data with decimal minimum value
george42-ctds 77d9e9e
(HP-2029) Change default log level to INFO
george42-ctds 0377039
(HP-2029) bump package version, change log level to info in redcap mo…
george42-ctds 290b823
(HP-2029) correct the version update
george42-ctds File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
CSV data to HEAL VLMD conversion | ||
""" | ||
|
||
from heal.vlmd.extract.json_dict_conversion import convert_template_json | ||
from heal.vlmd.mappings import typesets | ||
from heal.vlmd.validate.utils import read_delim | ||
|
||
|
||
def convert_dataset_csv(file_path, data_dictionary_props={}): | ||
""" | ||
Takes a CSV file containing data (not metadata) and | ||
infers each of it's variables data types and names. | ||
These inferred properties are then outputted as partially-completed | ||
HEAL variable level metadata files. That is, it outputs the `name` and `type` property. | ||
|
||
NOTE: this will be an invalid file as `description` is required | ||
for each variable. However, this serves as a great way to start | ||
the basis of a VLMD submission. | ||
""" | ||
df = read_delim(file_path) | ||
data_dictionary = data_dictionary_props.copy() | ||
fields = typesets.infer_frictionless_fields(df) | ||
data_dictionary["fields"] = fields | ||
|
||
package = convert_template_json(data_dictionary) | ||
return package |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this to be a CLI parameter right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, leaving the default as True, the SDK will mimic the current behavior of
healdata-utils
for filling in all fields for CSV conversions. We could later add it to the CLI if there were requests from users.