Index: src/django_gheat/gheat/management/commands/import_datafile.py
===================================================================
--- src/django_gheat/gheat/management/commands/import_datafile.py	(revision 9637)
+++ src/django_gheat/gheat/management/commands/import_datafile.py	(revision 9639)
@@ -188,4 +188,37 @@
 
 
+def import_file(filename,meetrondje):
+  counters = {
+    'ap_added' : 0, 'ap_total' : 0,
+    'ap_failed' : 0, 'ap_ignored' : 0,
+    'client_added' : 0, 'client_total' : 0,
+    'client_failed' : 0, 'client_ignored' : 0,
+    'meting_added' : 0, 'meting_total' : 0,
+    'meting_failed' : 0, 'meting_ignored' : 0
+    }
+
+  fh = open_file(filename)
+  if 'ns1' in filename:
+    (counters, ap_pool, client_pool, meting_pool) = netstumbler.process_ns1(fh, counters)
+  elif 'gpsxml' in filename:
+    (counters, ap_pool, client_pool, meting_pool) = kismet.process_gpsxml(fh, counters)
+  elif 'netxml' in filename:
+    (counters, ap_pool, client_pool, meting_pool) = kismet.process_netxml(fh, counters)
+  elif 'ScanResult' in filename:
+    (counters, ap_pool, client_pool, meting_pool) = droidstumbler.process_csv(fh, counters)
+  else:
+    raise CommandError("file '%s' format not recognized" % filename)
+
+  if ap_pool:
+    counters = import_accespoints(ap_pool, counters)
+  if client_pool:
+    counters = import_clients(client_pool, counters)
+  if meting_pool:
+    counters = import_metingen(meetrondje, meting_pool, counters)
+
+  logger.info("summary accespoints: total:%(ap_total)-6s added:%(ap_added)-6s failed:%(ap_failed)-6s ignored:%(ap_ignored)-6s" % counters)
+  logger.info("summary client     : total:%(client_total)-6s added:%(client_added)-6s failed:%(client_failed)-6s ignored:%(client_ignored)-6s" % counters)
+  logger.info("summary metingen   : total:%(meting_total)-6s added:%(meting_added)-6s failed:%(meting_failed)-6s ignored:%(meting_ignored)-6s" % counters)
+
 
 
@@ -245,51 +278,23 @@
 
     # Get Gheat Objects, pre-req
-    g, created = Gebruiker.objects.get_or_create(naam=options['gebruiker'],
+    gebruiker, created = Gebruiker.objects.get_or_create(naam=options['gebruiker'],
       email=options['email'])
-    a, created = Apparatuur.objects.get_or_create(kaart=options['kaart'])
+    apparatuur, created = Apparatuur.objects.get_or_create(kaart=options['kaart'])
 
     # Check if all files are valid
     for filename in args:
       logger.info("Processing '%s'" % filename)
-      mr, created = MeetRondje.objects.get_or_create(
+      meetrondje, created = MeetRondje.objects.get_or_create(
         datum=get_date(filename), naam=get_meetrondje(filename),
-        gebruiker=g, apparatuur=a)
+        gebruiker=gebruiker, apparatuur=apparatuur)
       if not created:
-        logger.error("Meetrondje '%s' already imported",  mr)
+        logger.error("Meetrondje '%s' already imported",  meetrondje)
         continue
 
-      counters = {
-        'ap_added' : 0, 'ap_total' : 0,
-        'ap_failed' : 0, 'ap_ignored' : 0,
-        'client_added' : 0, 'client_total' : 0,
-        'client_failed' : 0, 'client_ignored' : 0,
-        'meting_added' : 0, 'meting_total' : 0,
-        'meting_failed' : 0, 'meting_ignored' : 0
-        }
-      logger.info('Meetrondje: %s', mr)
-      meetbestand = MeetBestand(meetrondje=mr,is_imported=True)
+      logger.info('Meetrondje: %s', meetrondje)
+      meetbestand = MeetBestand(meetrondje=meetrondje,is_imported=True)
       meetbestand.bestand.save(os.path.basename(filename),File(open(filename)))
       meetbestand.save()
 
-      fh = open_file(filename)
-      if 'ns1' in filename:
-        (counters, ap_pool, client_pool, meting_pool) = netstumbler.process_ns1(fh, counters)
-      elif 'gpsxml' in filename:
-        (counters, ap_pool, client_pool, meting_pool) = kismet.process_gpsxml(fh, counters)
-      elif 'netxml' in filename:
-        (counters, ap_pool, client_pool, meting_pool) = kismet.process_netxml(fh, counters)
-      elif 'ScanResult' in filename:
-        (counters, ap_pool, client_pool, meting_pool) = droidstumbler.process_csv(fh, counters)
-      else:
-        raise CommandError("file '%s' format not recognized" % filename)
-
-      if ap_pool:
-        counters = import_accespoints(ap_pool, counters)
-      if client_pool:
-        counters = import_clients(client_pool, counters)
-      if meting_pool:
-        counters = import_metingen(mr, meting_pool, counters)
-
-      logger.info("summary accespoints: total:%(ap_total)-6s added:%(ap_added)-6s failed:%(ap_failed)-6s ignored:%(ap_ignored)-6s" % counters)
-      logger.info("summary client     : total:%(client_total)-6s added:%(client_added)-6s failed:%(client_failed)-6s ignored:%(client_ignored)-6s" % counters)
-      logger.info("summary metingen   : total:%(meting_total)-6s added:%(meting_added)-6s failed:%(meting_failed)-6s ignored:%(meting_ignored)-6s" % counters)
+      import_file(filename,meetrondje)
+
