lstautorta.utils.hdf5
Functions:
| Name | Description |
|---|---|
pd_read_hdf_with_retry |
Read a table in a hdf5 object into a pandas DataFrame |
pd_read_hdf_with_retry
pd_read_hdf_with_retry(path_or_buf, key=None, mode='r', nb_tries=20, retry_wait_time_s=0.5, retry_on_os_error=False, *args, **kwargs)
Read a table in a hdf5 object into a pandas DataFrame
This is a wrapper around pandas.read_hdf, that will try to open the file several time in case a
HDF5 "Resource temporary unavailable" error is raised, which happens if the file is already opened
in write mode by another process.
Optionally, it can also re-try to open the file if an OSError is raised. This can be useful with shared
file systems: when the file system is overburdened, the metadata may take to long to be loaded and an
existing file can be reported as not present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_or_buf
|
Path
|
Any valid string path is acceptable. Only supports the local file system, remote URLs and file-like objects are not supported. If you want to pass in a path object, pandas accepts any os.PathLike. Alternatively, pandas accepts an open pandas.HDFStore object. |
required |
key
|
str | None
|
The group identifier in the store. Can be omitted if the HDF file contains a single pandas object, by default None |
None
|
mode
|
str
|
Mode to use when opening the file. Ignored if path_or_buf is a pandas.HDFStore. Default is 'r'. |
'r'
|
nb_tries
|
int
|
Number of times to attempt opening the file, by default 20 |
20
|
retry_wait_time_s
|
float
|
Amount of time to wait, in seconds, between each opening attempt, by default 0.5. |
0.5
|
retry_on_os_error
|
bool
|
If True, the retry strategy will be used as well if opening the files fails with an OSError. If False, only the tables.exceptions.HDF5ExtError (raised when ressource is unavailable) are caught. By default False. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
A DataFrame containing the table content. |