How to use the tabulator.errors.Error function in tabulator

To help you get started, we’ve selected a few tabulator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frictionlessdata / tabulator-py / tests / test_errors.py View on Github external
def test(self):
        self.assertTrue(issubclass(errors.Error, Exception))
github frictionlessdata / tabulator-py / tabulator / row.py View on Github external
def get(self, header):
        """Get value by header.

        Parameters
        ----------
        header: str
            Header name.

        """

        # If no headers
        if self.__mapping is None:
            raise errors.Error('No headers are available.')

        return self.__mapping[header]
github frictionlessdata / tabulator-py / tabulator / iterator.py View on Github external
def headers(self, headers):
        """Set item headers.
        """
        if self.__count != 0:
            message = 'Headers could be set only before first item is emited.'
            raise errors.Error(message)
        self.__headers = headers
github frictionlessdata / tabulator-py / tabulator / loaders / text.py View on Github external
encoding = self.DEFAULT_ENCODING

        # Prepare bytes
        bytes = io.BufferedRandom(io.BytesIO())
        bytes.write(source.encode(encoding))
        bytes.seek(0)

        # Return or raise
        if mode == 'b':
            return bytes
        elif mode == 't':
            chars = io.TextIOWrapper(bytes, encoding, **self.__options)
            return chars
        else:
            message = 'Mode %s is not supported' % mode
            raise errors.Error(message)
github frictionlessdata / tabulator-py / tabulator / processors / strict.py View on Github external
if self.__dimension is None:
            self.__dimension = len(iterator.values)
        else:
            if self.__dimension != len(iterator.values):
                error = 'dimensions are not consistent'

        # Check headers/dimension
        if self.__headers is not None:
            if self.__dimension != len(self.__headers):
                error = 'headers/values have different dimensions'

        # Skip or raise exception
        if error:
            if self.__skip:
                return iterator.skip()
            raise errors.Error('Strict error: %s' % error)