Exemplo n.º 1
0
        try:
            reader = DatParser(params.filename)
            return (
                result.format(
                    count=sum(
                        1 for channel in reader.channels
                        if channel.enabled),
                    names=','.join(
                        channel.name for channel in reader.channels
                        if channel.enabled),
                    x_size=reader.x_size,
                    y_size=reader.y_size,
                    comments=reader.comments,
                ),
                True
            )
        except IOError as exc:
            return ('I/O error when opening file: {}'.format(exc), False)
        except Error as exc:
            return ('File does not appear to be a valid DAT file: {}'.format(exc), False)

    def doImport(self, params):
        reader = DatParser(params.filename)
        return [
            ImportDataset2D(channel.name, channel.data)
            for channel in reader.channels
        ]

importpluginregistry.append(ImportPluginDat)

Exemplo n.º 2
0
            reader = RasParser(params.filename,
                params.field_results.get('channels'))
            return (
                result.format(
                    count=sum(
                        1 for channel in reader.channels
                        if channel.enabled),
                    names=','.join(
                        channel.name for channel in reader.channels
                        if channel.enabled),
                    x_size=reader.x_size,
                    y_size=reader.y_size,
                    comments=reader.comments),
                True
            )
        except IOError as exc:
            return ('I/O error when opening file: {}'.format(exc), False)
        except Error as exc:
            return ('File does not appear to be a valid RAS file: {}'.format(exc), False)

    def doImport(self, params):
        reader = RasParser(params.filename,
            params.field_results.get('channels'))
        return [
            ImportDataset2D(channel.name, channel.data)
            for channel in reader.channels
            if channel.enabled
        ]

importpluginregistry.append(ImportPluginRas)
Exemplo n.º 3
0
"""
        try:
            reader = RasParser(params.filename,
                               params.field_results.get('channels'))
            return (result.format(count=sum(1 for channel in reader.channels
                                            if channel.enabled),
                                  names=','.join(channel.name
                                                 for channel in reader.channels
                                                 if channel.enabled),
                                  x_size=reader.x_size,
                                  y_size=reader.y_size,
                                  comments=reader.comments), True)
        except IOError as exc:
            return ('I/O error when opening file: {}'.format(exc), False)
        except Error as exc:
            return (
                'File does not appear to be a valid RAS file: {}'.format(exc),
                False)

    def doImport(self, params):
        reader = RasParser(params.filename,
                           params.field_results.get('channels'))
        return [
            ImportDataset2D(channel.name, channel.data)
            for channel in reader.channels if channel.enabled
        ]


importpluginregistry.append(ImportPluginRas)
Exemplo n.º 4
0
        data = [row for row in cursor]
        # Transpose the data from a list of row-tuples to a list of columns
        data = [
            [row[i] for row in data]
            for i, col in enumerate(cursor.description)]
        # Figure out the dataset name and type for each column
        names = sanitize_names(col[0] for col in cursor.description)
        classes = [
            ImportDatasetText if any(isinstance(value, basestring) for value in column) else ImportDataset1D
            for column in data]
        result = []
        for (name, cls, column) in zip(names, classes, data):
            if cls is ImportDataset1D:
                result.append(ImportDataset1D(
                    name, data=[
                        # Import NULL values as NaN in numeric datasets
                        float('NaN') if value is None else float(value)
                        for value in column]))
            else:
                result.append(ImportDatasetText(
                    name, data=[
                        # Import NULL values as blank strings in text datasets
                        '' if value is None else value
                        for value in column]))
        return result

importpluginregistry.append(ImportPluginSQLite)



Exemplo n.º 5
0
                first_col += 1
            else:
                names = [
                    'row{}'.format(i)
                    for i in range(first_row, last_row + 1)]
            data = [
                [cell for cell in sheet.row(row)[first_col:last_col + 1]]
                for row in range(first_row, last_row + 1)]
        names = sanitize_names(names)
        classes = [
            ImportDatasetText if any(cell.ctype == xlrd.XL_CELL_TEXT for cell in col) else ImportDataset1D
            for col in data]
        result = []
        for (name, cls, column) in zip(names, classes, data):
            if cls is ImportDataset1D:
                result.append(ImportDataset1D(
                    name, data=[
                        # Import non-numeric cells as NaN
                        float(cell.value) if cell.ctype == xlrd.XL_CELL_NUMBER else float('NaN')
                        for cell in column]))
            else:
                result.append(ImportDatasetText(
                    name, data=[
                        cell.value if cell.ctype == xlrd.XL_CELL_TEXT else ''
                        for cell in column]))
        return result

importpluginregistry.append(ImportPluginExcel)