# Path: openfisca_survey_manager/read_sas.py
# def read_sas(sas_file_path, clean = False):
#     try:
#         import pyreadstat
#         data_frame, _ = pyreadstat.read_sas7bdat(sas_file_path)
#     except ImportError as e1:
#         log.info("pyreadstat not available trying SAS7BDAT")
#         try:
#             from sas7bdat import SAS7BDAT
#             data_frame = SAS7BDAT(sas_file_path).to_data_frame()
#         except ImportError as e2:
#             log.info("Neither pyreadstat nor SAS7BDAT are available")
#             print(e1)
#             raise(e2)
# 
#     return data_frame


from chardet.universaldetector import UniversalDetector
from openfisca_survey_manager import read_sas
    from openfisca_survey_manager.read_spss import read_spss
        from .surveys import Survey  # Keep it here to avoid infinite recursion
import collections
import csv
import datetime
import gc
import logging
import os
import pandas
            self.name,
            data_file_path,
            self.survey.hdf5_file_path,
            self.name,
            ))

    def _save(self, data_frame = None):
        assert data_frame is not None
        table = self
        hdf5_file_path = table.survey.hdf5_file_path
        variables = table.variables
        log.info("Inserting table {} in HDF file {}".format(table.name, hdf5_file_path))
        if variables:
            stored_variables = list(set(variables).intersection(set(data_frame.columns)))
            log.info('The folloging variables are stored: {}'.format(stored_variables))
            if set(stored_variables) != set(variables):
                log.info('variables wanted by the user that were not available: {}'.format(
                    list(set(variables) - set(stored_variables))
                    ))
            data_frame = data_frame[stored_variables].copy()

        self.save_data_frame(data_frame)
        gc.collect()

    def fill_hdf(self, **kwargs):
        source_format = self.source_format

        reader_by_source_format = dict(
            # Rdata = pandas.rpy.common.load_data,
            csv = pandas.read_csv,

# Path: openfisca_survey_manager/read_sas.py
# def read_sas(sas_file_path, clean = False):
#     try:
#         import pyreadstat
#         data_frame, _ = pyreadstat.read_sas7bdat(sas_file_path)
#     except ImportError as e1:
#         log.info("pyreadstat not available trying SAS7BDAT")
#         try:
#             from sas7bdat import SAS7BDAT
#             data_frame = SAS7BDAT(sas_file_path).to_data_frame()
#         except ImportError as e2:
#             log.info("Neither pyreadstat nor SAS7BDAT are available")
#             print(e1)
#             raise(e2)
# 
#     return data_frame


# Path: openfisca_survey_manager/tables.py
from chardet.universaldetector import UniversalDetector
from openfisca_survey_manager import read_sas
    from openfisca_survey_manager.read_spss import read_spss
        from .surveys import Survey  # Keep it here to avoid infinite recursion
import collections
import csv
import datetime
import gc
import logging
import os
import pandas

            self.name,
            data_file_path,
            self.survey.hdf5_file_path,
            self.name,
            ))

    def _save(self, data_frame = None):
        assert data_frame is not None
        table = self
        hdf5_file_path = table.survey.hdf5_file_path
        variables = table.variables
        log.info("Inserting table {} in HDF file {}".format(table.name, hdf5_file_path))
        if variables:
            stored_variables = list(set(variables).intersection(set(data_frame.columns)))
            log.info('The folloging variables are stored: {}'.format(stored_variables))
            if set(stored_variables) != set(variables):
                log.info('variables wanted by the user that were not available: {}'.format(
                    list(set(variables) - set(stored_variables))
                    ))
            data_frame = data_frame[stored_variables].copy()

        self.save_data_frame(data_frame)
        gc.collect()

    def fill_hdf(self, **kwargs):
        source_format = self.source_format

        reader_by_source_format = dict(
            # Rdata = pandas.rpy.common.load_data,
            csv = pandas.read_csv,

            sas = read_sas.read_sas,