clarification
samwyse
dejanews at email.com
Fri Aug 17 22:32:02 EDT 2007
Scott David Daniels wrote:
> lefts = set()
> rights = set()
> with open('sheet1', 'r') as fh:
> for line in fh:
> trimmed = line.strip()
> if trimmed: # Skip blanks (file end often looks like that)
> left, right = line.strip().split('\t')
> lefts.add(left)
> rights.add(right)
> result = lefts & rights
>
> -Scott
# change to however many columns may later exist
cols = [ set() for i in range(0, 2) ]
with open('sheet1', 'r') as fh:
for line in fh:
for col, data in zip(cols, line.strip().split('\t')):
col.add(data)
result = cols[0] & cols[1]
More information about the Python-list
mailing list