alimanfoo/petl — pull request #215 by phillipknauss (2013-10-15 15:40:47+00:00)
Title: Add  'skip' and 'fill'  parameters to capture

As discussed in issue 207, adds the ability to specify the behavior of capture when the pattern does not match the field.

Previously, it would raise an exception.

This change adds the parameters 'skip' and 'fill' to allow customizing the behavior. If neither parameter is specified, it will raise an exception if the expression doesn't match. If skip is specified and True, the original row will be returned. If fill is specified as a list/tuple of callables which return the default value for each capture group, then rows that don't match will have the value in the new column set to the return result of the callable.

Includes tests for the new functionality.

Could probably stand to be refactored, but works as currently implemented.