Skip to content

Instantly share code, notes, and snippets.

@sora
Created June 3, 2011 17:52
Show Gist options
  • Save sora/1006785 to your computer and use it in GitHub Desktop.
Save sora/1006785 to your computer and use it in GitHub Desktop.
import os, sys, gzip
cnt = 0
wf = open('result.txt', 'a')
for file in sys.argv[1:]:
for line in gzip.open(file, 'rb'):
if cnt % 10000 == 0:
print cnt
o1 = o2 = o3 = o4 = str()
ipaddr, name = line[:-1].split(' ')
o1, o2, o3, o4 = ipaddr.split('.')
if os.path.isfile(o1+'/'+o2+'/'+o3):
for l in open(o1+'/'+o2+'/'+o3, 'r'):
if l[:-1] == ipaddr:
wf.write(line)
cnt = cnt + 1
wf.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment