add importer for languages
This commit is contained in:
parent
fe745429ee
commit
9fa4237708
|
@ -1,4 +1,4 @@
|
|||
from itfprofiles.models import City, STATE_CHOICES
|
||||
from itfprofiles.models import City, STATE_CHOICES, Language
|
||||
import csv
|
||||
|
||||
def import_cities(csv_filename):
|
||||
|
@ -19,3 +19,16 @@ def get_state(name):
|
|||
if name == s[1]:
|
||||
return s[0]
|
||||
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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user