From 9fa4237708e53bd2c7c713539eafcb0e9287e67f Mon Sep 17 00:00:00 2001 From: Sanjay B Date: Wed, 11 Jun 2014 11:17:24 +0530 Subject: [PATCH] add importer for languages --- itf/itfprofiles/importer.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/itf/itfprofiles/importer.py b/itf/itfprofiles/importer.py index a998f10..4c5b7a5 100644 --- a/itf/itfprofiles/importer.py +++ b/itf/itfprofiles/importer.py @@ -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 + +