load_spreadsheets
- pyhelpers.store.load_spreadsheets(path_to_spreadsheet, as_dict=True, verbose=False, **kwargs)
Load multiple sheets of an Microsoft Excel file.
- Parameters
path_to_spreadsheet (str or os.PathLike[str]) – path where a spreadsheet is saved
as_dict (bool) – whether to return the retrieved data as a dictionary type, defaults to
True
verbose (bool or int) – whether to print relevant information in console, defaults to
False
kwargs – [optional] parameters of pandas.ExcelFile.parse
- Returns
all worksheet in an Excel workbook from the specified file path
path_to_spreadsheet
- Return type
list or dict
Note
Example data can be referred to the functions
pyhelpers.store.save_multiple_spreadsheets()
andpyhelpers.store.save_spreadsheet()
.
Examples:
>>> from pyhelpers.store import load_spreadsheets >>> from pyhelpers.dirs import cd >>> dat_dir = cd("tests\data") >>> path_to_xlsx = cd(dat_dir, "dat.xlsx") >>> wb_data = load_spreadsheets(path_to_xlsx, verbose=True, index_col=0) Loading "tests\data\dat.xlsx" ... 'TestSheet1'. ... Done. 'TestSheet2'. ... Done. 'TestSheet11'. ... Done. 'TestSheet21'. ... Done. >>> list(wb_data.keys()) ['TestSheet1', 'TestSheet2', 'TestSheet11', 'TestSheet21'] >>> wb_data = load_spreadsheets(path_to_xlsx, as_dict=False, index_col=0) >>> type(wb_data) list >>> len(wb_data) 4 >>> wb_data[0] Longitude Latitude City London -0.127647 51.507322 Birmingham -1.902691 52.479699 Manchester -2.245115 53.479489 Leeds -1.543794 53.797418