How to use the goodtables.processors.StructureProcessor function in goodtables

To help you get started, we’ve selected a few goodtables 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 / goodtables-py / tests / test_structure.py View on Github external
def test_standalone_row_limit_out_range(self):

        limit = processors.StructureProcessor.ROW_LIMIT_MAX
        validator = processors.StructureProcessor(row_limit=(limit + 1))

        self.assertEqual(validator.row_limit, limit)
github frictionlessdata / goodtables-py / tests / test_structure.py View on Github external
def test_standalone_ignore_headerless_columns_true(self):

        filepath = os.path.join(self.data_dir, 'headerless_columns.csv')
        with io.open(filepath) as stream:
            validator = processors.StructureProcessor(
                ignore_headerless_columns=True)
            result, report, data = validator.run(stream)

            self.assertTrue(result)
github frictionlessdata / goodtables-py / tests / test_structure.py View on Github external
def test_standalone_fail_fast_true(self):

        filepath = os.path.join(self.data_dir, 'fail_fast_two_structure_errors.csv')
        with io.open(filepath) as stream:
            validator = processors.StructureProcessor(fail_fast=True)
            result, report, data = validator.run(stream)

            self.assertEqual(len(report.generate()['results']), 1)
github frictionlessdata / goodtables-py / tests / test_structure.py View on Github external
def test_standalone_custom_empty_strings(self):

        filepath = os.path.join(self.data_dir, 'empty_rows_custom.csv')
        with io.open(filepath) as stream:
            validator = processors.StructureProcessor(empty_strings=('-',))
            result, report, data = validator.run(stream)

            self.assertFalse(result)
github frictionlessdata / goodtables-py / goodtables / cli / main.py View on Github external
def structure(data, format, fail_fast, row_limit, report_limit, output):

    """Run a Good Tables StructureProcessor."""

    processor = processors.StructureProcessor(format=format, fail_fast=fail_fast,
                                              row_limit=row_limit,
                                              report_limit=report_limit)

    valid, report, data = processor.run(data)

    valid_msg = 'Well done! The data is valid :)\n'.upper()
    invalid_msg = 'Oops.The data is invalid :(\n'.upper()

    if output == 'json':
        exclude = None
    else:
        exclude = ['result_context', 'processor', 'row_name', 'result_category',
                   'column_index', 'column_name', 'result_level']

    if valid:
        click.echo(click.style(valid_msg, fg='green'))