Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import csv, psycopg2, operator
  2.  
  3. connection = psycopg2.connect("host='localhost' dbname='tpp_la_gridAAA' user='postgres' password='zia123'")
  4. cursor1 = connection.cursor()
  5. cursor2 = connection.cursor()
  6.  
  7. analysis = [{1:0},{2:0},{3:0},{4:0},{5:0},{6:0}]
  8.  
  9. sql = "select id from ways_vertices_pgr"
  10. cursor1.execute(sql)
  11. for result1 in cursor1:
  12. sql = "select count(*) from ways where source = '%s' or target = '%s'" % (result1[0], result1[0])
  13. cursor2.execute(sql)
  14. for result2 in cursor2:
  15. if result2[0] == 1:
  16. analysis[0][1] = analysis[0][1] + 1
  17. elif result2[0] == 2:
  18. analysis[1][2] = analysis[1][2] + 1
  19. elif result2[0] == 3:
  20. analysis[2][3] = analysis[2][3] + 1
  21. elif result2[0] == 4:
  22. analysis[3][4] = analysis[3][4] + 1
  23. elif result2[0] == 5:
  24. analysis[4][5] = analysis[4][5] + 1
  25. elif result2[0] == 6:
  26. analysis[5][6] = analysis[5][6] + 1
  27.  
  28.  
  29. print analysis
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement