How to remove subset from a file efficiently?
AJL
unixfd0.n0spam at yahoo.com
Thu Jan 12 15:00:27 EST 2006
On 12 Jan 2006 09:04:21 -0800
"fynali" <iladijas at gmail.com> wrote:
> Hi all,
>
> I have two files:
>
> - PSP0000320.dat (quite a large list of mobile numbers),
> - CBR0000319.dat (a subset of the above, a list of barred bumbers)
>
...
> Objective: to remove the numbers present in barred-list from the
> PSPfile.
How fast does this run?
a = set(file('PSP0000320.dat'))
b = set(file('CBR0000319.dat'))
file('PSP-CBR.dat', 'w').writelines(a.difference(b))
AJL
More information about the Python-list
mailing list