Skip to content
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

Add splitdown function #430

Merged
merged 2 commits into from Aug 6, 2019

Conversation

@John-Dennert
Copy link
Contributor

commented Sep 5, 2017

Added splitdown function (resolves #386).
Added unit test for splitdown function.
Ran tox -e py26,py27,py36 (I don't have Python 3.4 installed).

Desired results for the example provided in #386 could be accomplished using splitdown followed by split.

Ex.

tbl = (('ID', 'AMOUNT', 'RECIPIENT'),
       ('1', '1000', 'Joe: 25%, Jane: 75%'),
       ('2', '2000', 'Joe: 25%, Jess: 25%, Jenny: 25%, Jim: 25%'))

actual_step_1 = splitdown(tbl, 'RECIPIENT', ', ')
actual_step_2 = split(actual_step_1, 'RECIPIENT', ': ', newfields=['RECIPIENT', 'PERCENT'])
expect = (('ID', 'AMOUNT', 'RECIPIENT', 'PERCENT'),
          ('1', '1000', 'Joe', '25%'),
          ('1', '1000', 'Jane', '75%'),
          ('2', '2000', 'Joe', '25%'),
          ('2', '2000', 'Jess', '25%'),
          ('2', '2000', 'Jenny', '25%'),
          ('2', '2000', 'Jim', '25%'))

ieq(expect, actual_step_2)
ieq(expect, actual_step_2)
ieq(expect, actual_step_2)
ieq(expect, actual_step_2)
ieq(expect, actual_step_2)
ieq(expect, actual_step_2)
ieq(expect, actual_step_2)
John-Dennert added 2 commits Sep 5, 2017
Added splitdown function (resolves #386, #386).
Allows the use of a regex to split a field into new rows.
Added unit test for splitdown function.
All tests pass for py26, py27 and py36.

@alimanfoo alimanfoo changed the title Resolve issue #386 Add splitdown function Aug 6, 2019

@alimanfoo alimanfoo added this to the v1.3 milestone Aug 6, 2019

@alimanfoo

This comment has been minimized.

Copy link
Collaborator

commented Aug 6, 2019

Going to merge this but will follow up with change notes and a CI run in a separate PR (source branch is on an unknown repository).

@alimanfoo alimanfoo merged commit d819ceb into petl-developers:master Aug 6, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@alimanfoo alimanfoo referenced this pull request Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.