Commit 756be367 authored by Christophe Benz's avatar Christophe Benz
Browse files

Follow internalization of BytesLoader into validata-validate

parent 4b147afb
......@@ -41,7 +41,6 @@ class ValidataSource():
self.type = type
self.scheme = None
self.format = None
self.custom_loaders = {}
def get_goodtables_source(self):
""" Creates source ready to be ingested by tabulator """
......@@ -59,18 +58,6 @@ class ValidataSource():
# Else use custom BytesLoader
self.scheme = 'custom'
self.custom_loaders = {'custom': BytesLoader}
self.scheme = 'bytes'
return {'source':, 'format': self.format, 'scheme': self.scheme, "custom_loaders": self.custom_loaders}
class BytesLoader(Loader):
""" Custom loader for bytes string """
options = []
def __init__(self, bytes_sample_size, **options):
def load(self, source, mode='t', encoding=None):
return BytesIO(source)
return {'source':, 'format': self.format, 'scheme': self.scheme}
......@@ -9,6 +9,7 @@ from collections import OrderedDict
from pathlib import Path
from validata_validate import csv_helpers
from validata_validate.loaders import custom_loaders
from validata_ui_next import app
from validata_ui_next.util import flash_error, flash_info, flash_success, flash_warning, ValidataSource
from validata_ui_next.validate_helper import ValidatorHelper
......@@ -35,9 +36,10 @@ def extract_source_data(source: ValidataSource, preview_rows_nb=5):
delimiter = None
if source.format == "csv":
delimiter = csv_helpers.detect_dialect(, format=source.format,
scheme=source.scheme, custom_loaders=source.custom_loaders).delimiter
with tabulator.Stream(, format=source.format, scheme=source.scheme, custom_loaders=source.custom_loaders, delimiter=delimiter) as stream:
delimiter = csv_helpers.detect_dialect(, format=source.format, scheme=source.scheme,
with tabulator.Stream(, format=source.format, scheme=source.scheme, custom_loaders=custom_loaders,
delimiter=delimiter) as stream:
for row in stream:
if header is None:
header = row
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment