extracting duplicates from CSV file by specific fields

VP vadim.pestovnikov at gmail.com
Wed Apr 29 02:53:24 CEST 2009


Hi,
I have a csv file:

'aaa.111', 'T100', 'pn123', 'sn111'
'aaa.111', 'T200', 'pn123', 'sn222'
'bbb.333', 'T300', 'pn123', 'sn333'
'ccc.444', 'T400', 'pn123', 'sn444'
'ddd', 'T500', 'pn123', 'sn555'
'eee.666', 'T600', 'pn123', 'sn444'
'fff.777', 'T700', 'pn123', 'sn777'

How can I extract duplicates checking each row by filed1 and filed4?

I should get something like that:

'aaa.111', 'T100', 'pn123', 'sn111'
'bbb.333', 'T300', 'pn123', 'sn333'
'ccc.444', 'T400', 'pn123', 'sn444'
'ddd', 'T500', 'pn123', 'sn555'
'fff.777', 'T700', 'pn123', 'sn777'

and

'aaa.111', 'T200', 'pn123', 'sn222'
'eee.666', 'T600', 'pn123', 'sn444'

Any help will be extremely appreciated.




More information about the Python-list mailing list