add importer for languages

This commit is contained in:
Sanjay B 2014-06-11 11:17:24 +05:30
parent fe745429ee
commit 9fa4237708

View File

@ -1,4 +1,4 @@
from itfprofiles.models import City, STATE_CHOICES from itfprofiles.models import City, STATE_CHOICES, Language
import csv import csv
def import_cities(csv_filename): def import_cities(csv_filename):
@ -19,3 +19,16 @@ def get_state(name):
if name == s[1]: if name == s[1]:
return s[0] return s[0]
print "State %s not found" % name print "State %s not found" % name
def import_languages(csv_filename):
csv_file = open(csv_filename)
csv_reader = csv.reader(csv_file)
for row in csv_reader:
language = row[0].strip()
code = language[0:3].lower()
l = Language(code=code, name=language)
l.save()
print code, language