-
Notifications
You must be signed in to change notification settings - Fork 8
Capture column names and Regex column name matching #135
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
10 commits
Select commit
Hold shift + click to select a range
ff1f2ca
Allow regexp column names
ollietulloch e37f955
Map column name to field
ollietulloch b5addc5
Regexp column name testing
ollietulloch d0cbdf1
Store column name tests
ollietulloch 56fe1d1
Documentation
ollietulloch c637113
Changelog
ollietulloch 877ab40
Add a slightly convoluted test
ollietulloch 15b7b17
Mutate regex column names while iterating
ollietulloch 8754a17
Use `match?` instead of `=~` as a conditional
ollietulloch ebfffe9
typos
ollietulloch 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| --- | ||
| layout: page | ||
| title: Capturing Column Names in Mapped Data | ||
| permalink: /capturing-column-names/ | ||
| --- | ||
|
|
||
| Column names themselves may contain data that should be included in each record. For example VCF files have a column name that is a Lab Number and it should be included on all records. | ||
|
|
||
| In order to store the column name in each record, include the `map_columname_to` key at the column level, with the value being the desired field and rawtext name. | ||
|
|
||
|
|
||
| Example mapping | ||
|
|
||
| --- | ||
| - column: column_one | ||
| mappings: | ||
| - field: field_one | ||
| - column: abc123 | ||
| map_columname_to: 'columnname_field' | ||
| mappings: | ||
| - field: field_two | ||
|
|
||
| Example data: | ||
|
|
||
| ``` | ||
| "column_one","abc123" | ||
| "one","two" | ||
| ``` | ||
|
|
||
| This would result in: | ||
|
|
||
| ``` | ||
| { 'field_one' => 'one', | ||
| 'columnname_field' => 'abc123', | ||
| 'field_two' => 'two', | ||
| rawtext: { 'column_one' => 'one', 'abc123' => 'two', 'columnname_field' => 'abc123' } } | ||
| ``` | ||
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,44 @@ | ||
| --- | ||
| layout: page | ||
| title: Regular Expression Column Names | ||
| permalink: /regexp-column-names/ | ||
| --- | ||
|
|
||
| Column names may differ between files, for example a lab number might be used a column name. In order to map the column, the column name can be a regular expression. | ||
|
|
||
| If the regular expression matches the column name in the raw file, the data will be mapped and loaded as expected. | ||
|
|
||
| If the regular expected does not match the column name, a column header error will be raised. | ||
|
|
||
| Example mapping | ||
|
|
||
| --- | ||
| - column: /\A[A-Z]+\d{3}\z/i | ||
| mappings: | ||
| - field: regex_field | ||
| - column: two | ||
| mappings: | ||
| - field: two | ||
|
|
||
| Example data: | ||
|
|
||
| ``` | ||
| "abc123","two" | ||
| "regex_value","string_value" | ||
| ``` | ||
|
|
||
| This would result in: | ||
|
|
||
| ``` | ||
| { 'regex_field' => 'regex_value', 'two' => 'string_value' }, | ||
| rawtext: { 'regex_field' => 'regex_value', 'two' => 'string_value' } } | ||
| ``` | ||
|
|
||
| However, the below data: | ||
|
|
||
| ``` | ||
| "1234abc","two" | ||
| "regex_value,string_value" | ||
| ``` | ||
|
|
||
| would result in a RuntimeError: 'Header is not valid! unexpected: ["1234abc"]' |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.