Created
July 22, 2016 15:07
-
-
Save Zia-/77046b6a41f86b8bf3410dab604e76af to your computer and use it in GitHub Desktop.
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
import csv, psycopg2, operator | |
connection = psycopg2.connect("host='localhost' dbname='tpp_la_gridAAA' user='postgres' password='zia123'") | |
cursor1 = connection.cursor() | |
cursor2 = connection.cursor() | |
analysis = [{1:0},{2:0},{3:0},{4:0},{5:0},{6:0}] | |
sql = "select id from ways_vertices_pgr" | |
cursor1.execute(sql) | |
for result1 in cursor1: | |
sql = "select count(*) from ways where source = '%s' or target = '%s'" % (result1[0], result1[0]) | |
cursor2.execute(sql) | |
for result2 in cursor2: | |
if result2[0] == 1: | |
analysis[0][1] = analysis[0][1] + 1 | |
elif result2[0] == 2: | |
analysis[1][2] = analysis[1][2] + 1 | |
elif result2[0] == 3: | |
analysis[2][3] = analysis[2][3] + 1 | |
elif result2[0] == 4: | |
analysis[3][4] = analysis[3][4] + 1 | |
elif result2[0] == 5: | |
analysis[4][5] = analysis[4][5] + 1 | |
elif result2[0] == 6: | |
analysis[5][6] = analysis[5][6] + 1 | |
print analysis |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment