bblocks.import_tools.common

Classes

ImportData

Helper class that provides a standard way to create an ABC using

Functions

append_new_data(→ pandas.DataFrame)

Append new _data to an existing dataframe

get_response(→ requests.Response)

Get the response from a url

unzip(→ zipfile.ZipFile)

Unzip a file

Module Contents

class bblocks.import_tools.common.ImportData

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

_data: dict[str, pandas.DataFrame]
_raw_data: pandas.DataFrame | None = None
abstract load_data(**kwargs) ImportData

Load the _data saved on disk

abstract update_data(**kwargs) ImportData

Update object _data

get_data(indicators: str | list = 'all', **kwargs) pandas.DataFrame

Get the _data as a Pandas DataFrame

bblocks.import_tools.common.append_new_data(new_data: pandas.DataFrame, existing_data_path: str | pathlib.Path, parse_dates: list[str] | None) pandas.DataFrame

Append new _data to an existing dataframe

bblocks.import_tools.common.get_response(url: str) requests.Response

Get the response from a url

This function is used to get the response from a url. It will raise an error if the url is invalid or if the response is not 200.

Parameters:

url – url to get the response from

Returns:

response from the url

bblocks.import_tools.common.unzip(file: str | io.BytesIO) zipfile.ZipFile

Unzip a file

Create a ZipFile object from a file on disk or a file-like object from a requests response.

Parameters:
  • file – path to zipfile or file-like object. If zipfile is extracted from a url,

  • `io.BytesIO (the file like object can be obtained by calling) –

Returns:

object containing unzipped folder

Return type:

ZipFile