# Path: sitegeist/data/nhgis/models.py
# class Tract(models.Model):
# 
#     state = models.CharField(max_length=2)
#     county = models.CharField(max_length=3)
#     tract = models.CharField(max_length=12)
# 
#     year = models.CharField(max_length=4)
#     units = models.IntegerField(blank=True, null=True)
# 
#     class Meta:
#         ordering = ('state', 'county', 'tract')
# 
#     def __unicode__(self):
#         return u"%s:%s:%s" % (self.state, self.county, self.tract)


import csv
import os
from django.conf import settings
from sitegeist.data.nhgis.models import Tract




def load():

    Tract.objects.all().delete()

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

        count = 0

        reader = csv.DictReader(infile)

        for rec in reader:

            if count == 0:
                count += 1
                continue


# Path: sitegeist/data/nhgis/models.py
# class Tract(models.Model):
# 
#     state = models.CharField(max_length=2)
#     county = models.CharField(max_length=3)
#     tract = models.CharField(max_length=12)
# 
#     year = models.CharField(max_length=4)
#     units = models.IntegerField(blank=True, null=True)
# 
#     class Meta:
#         ordering = ('state', 'county', 'tract')
# 
#     def __unicode__(self):
#         return u"%s:%s:%s" % (self.state, self.county, self.tract)


# Path: sitegeist/data/nhgis/loading.py
import csv
import os
from django.conf import settings
from sitegeist.data.nhgis.models import Tract





def load():

    Tract.objects.all().delete()

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

        count = 0

        reader = csv.DictReader(infile)

        for rec in reader:

            if count == 0:
                count += 1
                continue


            Tract.objects.create(