top_pdport=sqlCtx.sql("SELECT dstport, count(dstport) as c1 FROM precords GROUP BY dstport ORDER BY c1 DESC LIMIT 10").map(lambdax:(x.dstport,x.c1)).collect()
print"Top Dest ports:"
print"{:>6} {:>12}".format("Dest Port","Count")
forport,countintop_port:
print"{:>6} {:>12}".format(port,count)
top_psport=sqlCtx.sql("SELECT srcport, count(srcport) as c1 FROM precords GROUP BY srcport ORDER BY c1 DESC LIMIT 10").map(lambdax:(x.srcport,x.c1)).collect()