extract_distritos.py
813 Bytes
import json
import sys
def main():
try:
with open('/yvyape/proyectos/sigem-gis/snc_full.json', 'r') as f:
data = json.load(f)
distritos = set()
for feature in data.get('features', []):
props = feature.get('properties', {})
dpto = props.get('cod_dpto')
dist = props.get('cod_dist')
if dpto and dist is not None:
distritos.add(f"{dpto}|{dist}")
with open('/tmp/dist_list.txt', 'w') as out:
for d in sorted(list(distritos)):
out.write(f"{d}\n")
print(f"Lista de {len(distritos)} distritos generada correctamente.")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()