def execute_import_task(self, task):
        """
            Execute each import job, in order
        """

        start = datetime.now()
        if task[0] == 1:
            s3db = current.s3db
            response = current.response
            errorString = "prepopulate error: file %s missing"
            # Store the view
            view = response.view

            _debug("Running job %s %s (filename=%s transform=%s)",
                   task[1],
                   task[2],
                   task[3],
                   task[4],
                   )

            prefix = task[1]
            name = task[2]
            tablename = "%s_%s" % (prefix, name)
            if tablename in self.alternateTables:
                details = self.alternateTables[tablename]
                if "tablename" in details:
                    tablename = details["tablename"]
                s3db.table(tablename)
                if "loader" in details:
                    loader = details["loader"]
                    if loader is not None:
                        loader()
                if "prefix" in details:
                    prefix = details["prefix"]
                if "name" in details:
                    name = details["name"]

            try:
                resource = s3db.resource(tablename)
            except __HOLE__:
                # Table cannot be loaded
                self.errorList.append("WARNING: Unable to find table %s import job skipped" % tablename)
                return

            # Check if the source file is accessible
            filename = task[3]
            if filename[:7] == "http://":
                req = urllib2.Request(url=filename)
                try:
                    f = urllib2.urlopen(req)
                except urllib2.HTTPError, e:
                    self.errorList.append("Could not access %s: %s" % (filename, e.read()))

                    return
                except:
                    self.errorList.append(errorString % filename)
                    return
                else:
                    csv = f
            else:
                try:
                    csv = open(filename, "r")
                except IOError:
                    self.errorList.append(errorString % filename)
                    return

            # Check if the stylesheet is accessible
            try:
                S = open(task[4], "r")
            except IOError:
                self.errorList.append(errorString % task[4])
                return
            else:
                S.close()

            # Customise the resource
            customise = current.deployment_settings.customise_resource(tablename)
            if customise:
                request = S3Request(prefix, name, current.request)
                customise(request, tablename)

            extra_data = None
            if task[5]:
                try:
                    extradata = self.unescape(task[5], {"'": '"'})
                    extradata = json.loads(extradata)
                    extra_data = extradata
                except:
                    self.errorList.append("WARNING:5th parameter invalid, parameter %s ignored" % task[5])
            auth = current.auth
            auth.rollback = True
            try:
                # @todo: add extra_data and file attachments
                resource.import_xml(csv,
                                    format="csv",
                                    stylesheet=task[4],
                                    extra_data=extra_data)
            except SyntaxError, e:
                self.errorList.append("WARNING: import error - %s (file: %s, stylesheet: %s)" %
                                     (e, filename, task[4]))
                auth.rollback = False
                return

            if not resource.error:
                current.db.commit()
            else:
                # Must roll back if there was an error!
                error = resource.error
                self.errorList.append("%s - %s: %s" % (
                                      task[3], resource.tablename, error))
                errors = current.xml.collect_errors(resource)
                if errors:
                    self.errorList.extend(errors)
                current.db.rollback()

            auth.rollback = False

            # Restore the view
            response.view = view
            end = datetime.now()
            duration = end - start
            csvName = task[3][task[3].rfind("/") + 1:]
            try:
                # Python 2.7
                duration = '{:.2f}'.format(duration.total_seconds() / 60)
                msg = "%s import job completed in %s mins" % (csvName, duration)
            except AttributeError:
                # older Python
                msg = "%s import job completed in %s" % (csvName, duration)
            self.resultList.append(msg)
            current.log.debug(msg)

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3/s3import.py/S3BulkImporter.execute_import_task