# Path: sitegeist/data/epa/models.py
# class Site(models.Model):
#     objects = models.GeoManager()
#     url = models.URLField()
#     point = models.PointField()


import csv
import os
from django.conf import settings
from django.contrib.gis.geos import fromstr
from sitegeist.data.epa.models import Site




def load():

    Site.objects.all().delete()

    path = os.path.join(settings.SITEGEIST['DATA_CACHE'], 'epa', 'contaminated.csv')
    with open(path) as infile:

        for (lat, lon, url) in csv.reader(infile):

            if lat and lon:

                pnt = fromstr('POINT(%s %s)' % (lon, lat), srid=4326)

# Path: sitegeist/data/epa/models.py
# class Site(models.Model):
#     objects = models.GeoManager()
#     url = models.URLField()
#     point = models.PointField()


# Path: sitegeist/data/epa/loading.py
import csv
import os
from django.conf import settings
from django.contrib.gis.geos import fromstr
from sitegeist.data.epa.models import Site





def load():

    Site.objects.all().delete()

    path = os.path.join(settings.SITEGEIST['DATA_CACHE'], 'epa', 'contaminated.csv')
    with open(path) as infile:

        for (lat, lon, url) in csv.reader(infile):

            if lat and lon:

                pnt = fromstr('POINT(%s %s)' % (lon, lat), srid=4326)

                Site.objects.create(url=url, point=pnt)