Index: /main/waeup.kofa/trunk/tools/fix_import_file.py
===================================================================
--- /main/waeup.kofa/trunk/tools/fix_import_file.py	(revision 8780)
+++ /main/waeup.kofa/trunk/tools/fix_import_file.py	(revision 8781)
@@ -17,5 +17,6 @@
 ##
 """
-Fix exports from old SRP portal to make them importable by current portal.
+Fix exports from old SRP portal and other data sources to make
+them importable by current portal.
 
 Usage:
@@ -28,4 +29,8 @@
 Errors/warnings will be displayed on the shell, the output will be put
 into the specified output file.
+
+
+The lgas.py module must be copied into the same folder where this script
+is started.
 """
 import csv
@@ -33,4 +38,21 @@
 import re
 import sys
+
+try:
+    from lgas import LGAS
+except:
+    print 'ERROR: lgas.py is missing.'
+    sys.exit(1)
+
+def strip(string):
+    string = string.replace('_', '')
+    string = string.replace('/', '')
+    string = string.replace('-', '')
+    string = string.replace(' ', '')
+    string = string.lower()
+    return string
+
+LGAS_inverted_stripped = dict([(strip(i[1]), i[0]) for i in LGAS])
+LGAS_dict = dict(LGAS)
 
 ##
@@ -189,4 +211,9 @@
         except:
             return ''
+        if value in LGAS_dict.keys():
+            return value
+        # If real names are given, let's see if a similar value
+        # in LGAS exist.
+        value = LGAS_inverted_stripped.get(strip(value), value)
         return value
 
@@ -232,7 +259,7 @@
         """ 'True'/'False' --> 'f'/'m'
         """
-        if value in ('True','f'):
+        if value in ('F', 'True','f'):
             value = 'f'
-        elif value in ('False','m'):
+        elif value in ('M', 'False','m'):
             value = 'm'
         else:
