Skip to content

Instantly share code, notes, and snippets.

@serkanh
Created September 16, 2012 15:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serkanh/3732778 to your computer and use it in GitHub Desktop.
Save serkanh/3732778 to your computer and use it in GitHub Desktop.
Simple CSV importer
from django.core.management import setup_environ
import settings, csv
setup_environ(settings)
from companies.models import Lead
file = csv.reader(open('florida.csv', 'rU'), delimiter = ',', quotechar='|')
for row in file:
#Name the Django field with corresponding row in your csv.
lead = Lead(cname=row[0], crep=row[1], cnumber=row[2], cemail=row[3], caddress=row[4], ccity=row[5],czip=row[6],submissiondate=row[7], businesstype = row[8], comment = row[9])
lead.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment