Commit 9e009c5a authored by Renán Sosa Guillen's avatar Renán Sosa Guillen

db population

parent b0133c01
# -*- coding: utf-8 -*-
"""
This script saves in DB the info from geojson files.
Receives as parameter the path where geojson files are located.
Usage:
$ cd GeoInt_SIDT
$ python manage.py populate_db [path/of/geojson/files]
Example:
$ cd GeoInt_SIDT
$ python manage.py populate_db /home/emmanuelhp/Documentos/geojson/
"""
from django.core.management.base import BaseCommand, CommandError
from catalog.models import Polygon
import json, unicodedata
class Command(BaseCommand):
def add_arguments(self, parser):
## positional arguments
parser.add_argument('geojson_path', nargs=1, type=str)
def handle(self, *args, **options):
#base path
base_path = '/home/emmanuelhp/Documentos/geojson/'
## base geojson files path
base_path = options['geojson_path'][0]
# loads files
# loading files
for index in range(1,33):
with open(base_path + str(index)+'.geojson') as f:
with open(base_path + str(index) + ".geojson") as f:
data = json.load(f)
print ("Index: ", index)
for feat in data['features']:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment