Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. # https://data.mos.ru/opendata/893
  2. # https://data.mos.ru/opendata/1251
  3.  
  4. import json
  5.  
  6. import openpyxl
  7.  
  8. wb = openpyxl.load_workbook('sports.xlsx')
  9. sh = wb.active
  10. nmin = sh.cell(row=7, column=2).value
  11. dct = {}
  12. flag = False
  13. for row in sh.rows:
  14.     if not flag:
  15.         flag = True
  16.         continue
  17.     area = row[4].value
  18.     district = row[5].value
  19.     address = row[6].value
  20.     dct.setdefault(area, {})
  21.     dct[area].setdefault(district, [])
  22.     dct[area][district].append(address)
  23.  
  24. fin = open('sports.json', 'w', encoding='utf-8')
  25. json.dump(dct, fp=fin, ensure_ascii=False)
  26. fin.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement