Created
November 30, 2011 00:32
-
-
Save adamcrosby/1407351 to your computer and use it in GitHub Desktop.
RIB Condenser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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