Load table from table config dict

    Args:
        input_dir (path-like): directory containing input files
        config (dict): mapping with keys 'name', 'path', and 'pd_read_kwargs'.

    Returns:
        pd.DataFrame
173646
def load_table_from_config(input_dir, config):
    
    path = pathlib.Path(input_dir).joinpath(config['path'])
    kwargs = config['pd_read_kwargs']
    return pd.read_csv(path, **kwargs)
511512
def populate_table(self, scenario_directory):
        
        parsed_files = []
        unparsed_files = []
        self.table.clearContents()

        # Block signal to allow update checking only when the table is ready
        self.table.blockSignals(True)
        # NOTE(gigih): need this line to remove existing rows
        self.table.setRowCount(0)

        if not os.path.exists(scenario_directory):
            # LOGGER.info('Scenario directory does not exist: %s' % path)
            return

        # only support .py and .txt files
        for current_path in os.listdir(scenario_directory):
            extension = os.path.splitext(current_path)[1]
            absolute_path = os.path.join(scenario_directory, current_path)

            if extension == '.py':
                append_row(self.table, current_path, absolute_path)
            elif extension == '.txt':
                # insert scenarios from file into table widget
                try:
                    scenarios = read_scenarios(absolute_path)
                    validate_scenario(scenarios, scenario_directory)
                    for key, value in list(scenarios.items()):
                        append_row(self.table, key, value)
                    parsed_files.append(current_path)
                except Error:
                    unparsed_files.append(current_path)

        # unblock signal
        self.table.blockSignals(False)
421793
def make_dict(cls, table):
        
        ret_dict = {}
        for row in table:
            file_handle = cls.create_from_row(row)
        ret_dict[file_handle.key] = file_handle
        return ret_dict
338777
def importDirectory(self, login, tableName, importDir, failureDir, setTime):
    
    self.send_importDirectory(login, tableName, importDir, failureDir, setTime)
    self.recv_importDirectory()
288919
def load(config_path, run_number=0, device='cuda:0'):
    
    model_config = ModelConfig.from_file(config_path, run_number, device=device)

    return model_config
704955
def load_data(self, path, *args, **kwargs):
        """"""
        self.df = self._load(path,*args, **kwargs)
        self.series = self.df.iloc[:,0]
        print ("Success! file length: " +str(self.df.shape[0]))
135947
def load(hdfs_path, **kwargs):
    
    m, _ = common.parse_mode(kwargs.get("mode", "r"))
    if m != "r":
        raise ValueError("opening mode must be readonly")
    with open(hdfs_path, **kwargs) as fi:
        data = fi.read()
    fi.fs.close()
    return data
864428
def load(dirname):
    """"""
    if not os.path.exists(dirname):
        raise AttributeError('No txt database named %s' % dirname)

    db = Database(dirname, dbmode='a')
    chain_folders = [os.path.join(dirname, c) for c in db.get_chains()]
    db.chains = len(chain_folders)

    data = {}
    for chain, folder in enumerate(chain_folders):
        files = os.listdir(folder)
        funnames = funname(files)
        db.trace_names.append(funnames)
        for file in files:
            name = funname(file)
            if name not in data:
                data[
                    name] = {
                }  # This could be simplified using "collections.defaultdict(dict)". New in Python 2.5
            # Read the shape information
            with open(os.path.join(folder, file)) as f:
                f.readline()
                shape = eval(f.readline()[16:])
                data[
                    name][
                        chain] = np.loadtxt(
                            os.path.join(
                                folder,
                                file),
                            delimiter=',').reshape(
                                shape)
                f.close()

    # Create the Traces.
    for name, values in six.iteritems(data):
        db._traces[name] = Trace(name=name, value=values, db=db)
        setattr(db, name, db._traces[name])

    # Load the state.
    statefile = os.path.join(dirname, 'state.txt')
    if os.path.exists(statefile):
        with open(statefile, 'r') as f:
            db._state_ = eval(f.read())
    else:
        db._state_ = {}

    return db
893435
async def _load(self):
        

        key = self._kwargs['key']
        pos = self._kwargs['pos']
        neg = self._kwargs['neg']

        with open(self._file_path, newline='', encoding='utf-8') as f:
            reader = csv.reader(f)
            data = {}

            for row in reader:
                try:
                    data[row[key]] = data.get(row[key], []) + [
                        tuple(extract_ranges(row, [pos] + neg))
                    ]
                except IndexError:
                    pass

        self._update({self._locale: data})
366190
def new_db_from_pandas(self, frame, table=None, data=None, load=True, **kwargs):
        

        from ..orm import Column
        # from dbexceptions import ConfigurationError

        # Create the table from the information in the data frame.
        with self.bundle.session:
            sch = self.bundle.schema
            t = sch.new_table(table)

            if frame.index.name:
                id_name = frame.index.name
            else:
                id_name = 'id'

            sch.add_column(t, id_name,
                           datatype=Column.convert_numpy_type(frame.index.dtype),
                           is_primary_key=True)

            for name, type_ in zip([row for row in frame.columns],
                                   [row for row in frame.convert_objects(convert_numeric=True,
                                                                         convert_dates=True).dtypes]):
                sch.add_column(t, name, datatype=Column.convert_numpy_type(type_))
                sch.write_schema()

        p = self.new_partition(table=table, data=data, **kwargs)

        if load:
            pk_name = frame.index.name
            with p.inserter(table) as ins:
                for i, row in frame.iterrows():
                    d = dict(row)
                    d[pk_name] = i

                    ins.insert(d)
        return p
1217782
def import_from_dicts(data, samples=None, *args, **kwargs):
    

    data = iter(data)

    cached_rows, headers = [], []
    for index, row in enumerate(data, start=1):
        cached_rows.append(row)

        for key in row.keys():
            if key not in headers:
                headers.append(key)

        if samples and index == samples:
            break

    data_rows = (
        [row.get(header, None) for header in headers]
        for row in chain(cached_rows, data)
    )

    kwargs["samples"] = samples
    meta = {"imported_from": "dicts"}
    return create_table(chain([headers], data_rows), meta=meta, *args, **kwargs)
774741
def read_parameters(self, input_dir):
        

        if self.show_progress:
            pbar = setup_progressbar("Loading parameters", len(self.records))
            pbar.start()
        for i, rec in enumerate(self.records):
            hook = os.path.join(input_dir, '{}.json*'.format(rec.name))
            filename = glob.glob(hook)
            try:
                with fileIO.freader(filename[0]) as infile:
                    d = json.loads(infile.read().decode('utf-8'), parse_int=True)

                rec.parameters.construct_from_dict(d)

            except (IOError, IndexError):
                continue

            finally:
                if self.show_progress:
                    pbar.update(i)
        if self.show_progress:
            pbar.finish()
767972
def input_dir(self):
        
        return os.path.abspath(os.path.dirname(self.inputs['job_ini']))
670107
def dir_import_table(self):
        
        import_header = list(self.optional_data_directories)[1]
        import_offset = self.resolve_rva(import_header.VirtualAddress)

        i = 0
        while True:
            offset = import_offset + i*Import_DirectoryTable.get_size()
            idt = Import_DirectoryTable(self.stream, offset, self)

            if idt.is_empty():
                break
            else:
                yield idt

            i += 1
457697
def load_data_table(file,
                    index_col,
                    show_progress=False):
    
    with ZipFile(file) as zip_file:
        file_names = zip_file.namelist()
        assert len(file_names) == 1, "Expected a single file from Quandl."
        wiki_prices = file_names.pop()
        with zip_file.open(wiki_prices) as table_file:
            if show_progress:
                log.info('Parsing raw data.')
            data_table = pd.read_csv(
                table_file,
                parse_dates=['date'],
                index_col=index_col,
                usecols=[
                    'ticker',
                    'date',
                    'open',
                    'high',
                    'low',
                    'close',
                    'volume',
                    'ex-dividend',
                    'split_ratio',
                ],
            )

    data_table.rename(
        columns={
            'ticker': 'symbol',
            'ex-dividend': 'ex_dividend',
        },
        inplace=True,
        copy=False,
    )
    return data_table
1272303
def get_input_dir(job_homedir=None):
    '''
    
    '''
    if job_homedir is not None:
        home_dir = job_homedir
    else:
        home_dir = environ.get('HOME')
    idir = os.path.join(home_dir, 'in')
    return idir
1328432
def _load_dataframe(self, resource_name):
        
        try:
            import pandas
        except ImportError:
            raise RuntimeError('To enable dataframe support, '
                               'run \'pip install datadotworld[pandas]\'')

        tabular_resource = self.__tabular_resources[resource_name]
        field_dtypes = fields_to_dtypes(tabular_resource.descriptor['schema'])

        try:
            return pandas.read_csv(
                path.join(
                    self.__base_path,
                    tabular_resource.descriptor['path']),
                dtype=field_dtypes['other'],
                parse_dates=list(field_dtypes['dates'].keys()),
                infer_datetime_format=True)
        except ValueError as e:
            warnings.warn(
                'Unable to set data frame dtypes automatically using {} '
                'schema. Data types may need to be adjusted manually. '
                'Error: {}'.format(resource_name, e))
            return pandas.read_csv(
                path.join(
                    self.__base_path,
                    tabular_resource.descriptor['path']))