Notes supporting issue #256.


In [1]:
import petl.interactive as etl

In [2]:
t1 = etl.wrap([['foo', 'bar'], [1, 'a'], [2, 'b']])
t1


Out[2]:
foo bar
1 a
2 b

In [3]:
t2 = etl.wrap([['foo', 'bar'], [1, 'a'], [2, 'c']])
t2


Out[3]:
foo bar
1 a
2 c

In [5]:
t3 = etl.merge(t1, t2, key='foo')
t3


Out[5]:
foo bar
1 a
2 Conflict(['c', 'b'])

The problem with the above is that you cannot tell from inspecting t3 alone which conflicting value comes from which source.

A workaround as suggested by @pawl is to use the conflicts() function, e.g.:


In [9]:
t4 = (etl
    .cat(
        t1.addfield('source', 1),
        t2.addfield('source', 2)
    )
    .conflicts(key='foo', exclude='source')
)
t4


Out[9]:
foo bar source
2 b 1
2 c 2