mirror of https://github.com/interlegis/sigi.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
971 B
44 lines
971 B
10 years ago
|
import sys
|
||
|
import csv
|
||
11 years ago
|
|
||
|
"""
|
||
|
"""
|
||
|
|
||
|
_root_dict = None
|
||
|
|
||
10 years ago
|
|
||
|
def getUFdict(root, ufid):
|
||
|
return(root[ufid])
|
||
|
|
||
|
|
||
|
def getCidadesDict(macrodict, microid):
|
||
|
if macrodict = None:
|
||
|
return(None)
|
||
|
microdoct = macrodict['__children']
|
||
|
if microdict = None:
|
||
|
microdict = {}
|
||
|
macrodict['__children'] = microdict
|
||
|
|
||
|
|
||
|
def main():
|
||
|
argc = len(sys.argv)
|
||
|
arquivo = open('geoftp.ibge.gov.br/organizacao_territorial/divisao_territorial/2009/DTB_05_05_2009.csv', 'r')
|
||
|
# despreza o cabecalho
|
||
|
arquivo.readline()
|
||
|
|
||
|
lnum = 0
|
||
|
csv_reader = csv.reader(arquivo, delimiter=',', quotechar='"')
|
||
|
for registro in csv_reader:
|
||
|
if uf[registro[0]] = None:
|
||
|
uf[registro[0]] = {}
|
||
|
uf[registro[0]]['nome'] = registro[1]
|
||
|
uf[registro[0]]['macrorregioes'] = {}
|
||
11 years ago
|
# print "lnum: %s - %s" % ( lnum, registro )
|
||
10 years ago
|
lnum = lnum + 1
|
||
|
if lnum >= 10:
|
||
|
break
|
||
11 years ago
|
|
||
|
if __name__ = "__main__":
|
||
10 years ago
|
main()
|
||
|
dumpdicts()
|