load_data

pyhelpers.store.load_data(path_to_file, err_warning=True, **kwargs)

Load data from a file.

Parameters
Returns

loaded data

Return type

any

Note

Examples:

>>> from pyhelpers.store import load_data
>>> from pyhelpers.dirs import cd

>>> data_dir = cd("tests\data")

>>> dat_pathname = cd(data_dir, "dat.pickle")
>>> pickle_dat = load_data(path_to_file=dat_pathname, verbose=True)
Loading "tests\data\dat.pickle" ... Done.
>>> pickle_dat
            Longitude   Latitude
City
London      -0.127647  51.507322
Birmingham  -1.902691  52.479699
Manchester  -2.245115  53.479489
Leeds       -1.543794  53.797418

>>> dat_pathname = cd(data_dir, "dat.csv")
>>> csv_dat = load_data(path_to_file=dat_pathname, index=0, verbose=True)
Loading "tests\data\dat.csv" ... Done.
>>> csv_dat
            Longitude   Latitude
City
London      -0.127647  51.507322
Birmingham  -1.902691  52.479699
Manchester  -2.245115  53.479489
Leeds       -1.543794  53.797418

>>> dat_pathname = cd(data_dir, "dat.json")
>>> json_dat = load_data(path_to_file=dat_pathname, verbose=True)
Loading "tests\data\dat.json" ... Done.
>>> json_dat
{'London': {'Longitude': -0.1276474, 'Latitude': 51.5073219},
 'Birmingham': {'Longitude': -1.9026911, 'Latitude': 52.4796992},
 'Manchester': {'Longitude': -2.2451148, 'Latitude': 53.4794892},
 'Leeds': {'Longitude': -1.5437941, 'Latitude': 53.7974185}}

>>> dat_pathname = cd(data_dir, "dat.feather")
>>> feather_dat = load_data(path_to_file=dat_pathname, index=0, verbose=True)
Loading "tests\data\dat.feather" ... Done.
>>> feather_dat
            Longitude   Latitude
City
London      -0.127647  51.507322
Birmingham  -1.902691  52.479699
Manchester  -2.245115  53.479489
Leeds       -1.543794  53.797418

>>> dat_pathname = cd(data_dir, "dat.joblib")
>>> joblib_dat = load_data(path_to_file=dat_pathname, verbose=True)
Loading "tests\data\dat.joblib" ... Done.
>>> joblib_dat
array([[0.5488135 , 0.71518937, 0.60276338, ..., 0.02010755, 0.82894003,
        0.00469548],
       [0.67781654, 0.27000797, 0.73519402, ..., 0.25435648, 0.05802916,
        0.43441663],
       [0.31179588, 0.69634349, 0.37775184, ..., 0.86219152, 0.97291949,
        0.96083466],
       ...,
       [0.89111234, 0.26867428, 0.84028499, ..., 0.5736796 , 0.73729114,
        0.22519844],
       [0.26969792, 0.73882539, 0.80714479, ..., 0.94836806, 0.88130699,
        0.1419334 ],
       [0.88498232, 0.19701397, 0.56861333, ..., 0.75842952, 0.02378743,
        0.81357508]])