-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement a transformation with if-else semantics #24
Comments
Syntax 1version: 1
columns:
phone:
- input: phone
- match?: "\d{10}"
- prepend: "1"
- else:
- value: "" If the phone number matches specified pattern, we preprend 1. Otherwise, we replace it with an empty value. The difficulty here is as follows. (Via typing, probably.) |
Syntax 2version: 1
columns:
phone:
- input: phone
- if:
conditon:
- match: "\d{10}"
then:
- prepend: "1"
else:
- value: "" Kind of verbose, but more understandable. |
Syntax 3I am trying to express things monadically here. version: 1
columns:
phone:
- input: phone
- match: "\d{10}"
- map:
- prepend: "1"
- fix:
- value: "" I am afraid this is immensely verbose and will mean that every step in the algorithm must be tagged with a I believe that, generally, every step in the transformations chain can be assumed to be a |
Syntax 4 (impossible)version: 1
columns:
phone:
- input: phone
? - match: "\\d{10}"
:
- then:
- prepend: "1"
- else:
- value: "" I tried to use the composite key syntax, but it only works at https://onlineyamltools.com/convert-yaml-to-json if the |
Syntax 5 (actually 2 but improved)version: 1
columns:
phone:
- input: phone
- match?:
pattern: "\d{10}"
then:
- prepend: "1"
else:
- value: "" This is less verbose, but more specialized than the
etc. But this will also make the language more readable. P. S. Will it? Say you need to compare the length of the string. Will you create separate functions for this, like
I can see such a feature being very useful in multiple contexts of cleaning data. |
Syntax 6version: 1
columns:
phone:
- input: phone
- if: {match: /\d{10}/}
then: {prepend: "1"}
else: {value: ""} Shorthand syntax for a familiar |
After some thought, I'd like to postpone this implementation due to the following reasons:
|
Example usecases:
...and whatever. We need to come up with:
The text was updated successfully, but these errors were encountered: