Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement