# Path: mfr/extensions/tabular/exceptions.py
# class EmptyTableError(TabularRendererError):
# 
#     __TYPE = 'tabular_empty_table'
# 
#     def __init__(self, message, *args, code: int=400, **kwargs):
#         super().__init__(message, *args, code=code, **kwargs)
#         self.attr_stack.append([self.__TYPE, {}])
# 
# class TabularRendererError(RendererError):
# 
#     def __init__(self, message, *args, **kwargs):
#         super().__init__(message, *args, renderer_class='tabular', **kwargs)
# 
# Path: mfr/extensions/tabular/utilities.py
# def header_population(headers):
# def data_population(in_data, headers=None):
# def strip_comments(src, dest):
# def sav_to_csv(fp):


import re
import csv
from mfr.extensions.tabular.exceptions import EmptyTableError, TabularRendererError
from mfr.extensions.tabular import utilities
            'sortable': True,
        })

    try:
        rows = [row for row in reader]
    except csv.Error as e:
        if any("field larger than field limit" in errorMsg for errorMsg in e.args):
            raise TabularRendererError(
                'This file contains a field too large to render. '
                'Please download and view it locally.',
                code=400,
                extension='csv',
            ) from e
        else:
            raise TabularRendererError('csv.Error: {}'.format(e), extension='csv') from e

    if not columns and not rows:
        raise EmptyTableError('Table empty or corrupt.', extension='csv')

    del reader
    return {'Sheet 1': (columns, rows)}


def sav_stdlib(fp):
    """Read and convert a .sav file to .csv with pspp, then convert that to JSON format using
    the python standard library

    :param fp: File pointer object to a .sav file
    :return: tuple of table headers and data
    """

# Path: mfr/extensions/tabular/exceptions.py
# class EmptyTableError(TabularRendererError):
# 
#     __TYPE = 'tabular_empty_table'
# 
#     def __init__(self, message, *args, code: int=400, **kwargs):
#         super().__init__(message, *args, code=code, **kwargs)
#         self.attr_stack.append([self.__TYPE, {}])
# 
# class TabularRendererError(RendererError):
# 
#     def __init__(self, message, *args, **kwargs):
#         super().__init__(message, *args, renderer_class='tabular', **kwargs)
# 
# Path: mfr/extensions/tabular/utilities.py
# def header_population(headers):
# def data_population(in_data, headers=None):
# def strip_comments(src, dest):
# def sav_to_csv(fp):


# Path: mfr/extensions/tabular/libs/stdlib_tools.py
import re
import csv
from mfr.extensions.tabular.exceptions import EmptyTableError, TabularRendererError
from mfr.extensions.tabular import utilities

            'sortable': True,
        })

    try:
        rows = [row for row in reader]
    except csv.Error as e:
        if any("field larger than field limit" in errorMsg for errorMsg in e.args):
            raise TabularRendererError(
                'This file contains a field too large to render. '
                'Please download and view it locally.',
                code=400,
                extension='csv',
            ) from e
        else:
            raise TabularRendererError('csv.Error: {}'.format(e), extension='csv') from e

    if not columns and not rows:
        raise EmptyTableError('Table empty or corrupt.', extension='csv')

    del reader
    return {'Sheet 1': (columns, rows)}


def sav_stdlib(fp):
    """Read and convert a .sav file to .csv with pspp, then convert that to JSON format using
    the python standard library

    :param fp: File pointer object to a .sav file
    :return: tuple of table headers and data
    """

    csv_file = utilities.sav_to_csv(fp)