Skip to content

Instantly share code, notes, and snippets.

@adamcrosby
Created November 30, 2011 00:32
Show Gist options
  • Save adamcrosby/1407351 to your computer and use it in GitHub Desktop.
Save adamcrosby/1407351 to your computer and use it in GitHub Desktop.
RIB Condenser
#!/usr/bin/env python
#With RIB size of 452M this takes forever to run:
#real 5923m20.767s
#user 5889m16.408s
#sys 33m48.739s
## DO NOT USE
with open("rib.dat") as RIB:
routes = {}
for line in RIB:
entry = line.strip().split('\t')
route = entry[0]
asn = entry[-1]
if route not in routes.keys():
routes[route] = [asn]
else:
if asn not in routes[route]:
routes[route].append(asn)
for route in routes.keys():
for asn in routes[route]:
print route + "\t" + asn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment