database.resources.packaging ============================ .. py:module:: database.resources.packaging .. autoapi-nested-parse:: This script houses functions for packaging the data. Attributes ---------- .. autoapisummary:: database.resources.packaging.EXPORT_DIR database.resources.packaging.FULL_DATAPACKAGE_DIR database.resources.packaging.INDV_DATAPACKAGE_DIR database.resources.packaging.METADATA_DIR Functions --------- .. autoapisummary:: database.resources.packaging.create_data_dictionary database.resources.packaging.create_data_package database.resources.packaging.create_individual_data_packages database.resources.packaging.export_data_csv database.resources.packaging.export_data_dictionaries database.resources.packaging.generate_dictionaries database.resources.packaging.load_json Module Contents --------------- .. py:function:: create_data_dictionary(metadata_dictionary: dict) Creates a data dictionary from the metadata. :param metadata_dictionary: Dictionary of Frictionless JSON metadata. :type metadata_dictionary: dict :returns: Pandas DataFrame resource schema fields. :rtype: pd.DataFrame (pd.DataFrame) .. py:function:: create_data_package() This function creates a datapackage. .. py:function:: create_individual_data_packages() Creates data packages for each product :param None.: :returns: None. .. note:: Parses the data-package directory for pairs of dictionary and data file pairs. .. py:function:: export_data_csv(dataframe: polars.DataFrame, filename: str) Exports the table to a CSV file. :param dataframe: Table to write out. :type dataframe: pl.DataFrame :param filename: Filename to write to. :type filename: str .. note:: Do not include file extensions in the filename. .. py:function:: export_data_dictionaries(data_dictionary: pandas.DataFrame) Creates individual data dictionaries for each resource. :param data_dictionary: Data dictionary of all resources. :type data_dictionary: pd.DataFrame :returns: None .. py:function:: generate_dictionaries() Calls functions in the required order. :param None: :returns: None .. py:function:: load_json(file_path: str) Imports the Frictionless JSON datapackage metadata. :param file_path: Filepath to the Frictionless JSON datapackage metadata. :type file_path: str :returns: Dictionary class of metadata :rtype: metadata (dict) .. py:data:: EXPORT_DIR .. py:data:: FULL_DATAPACKAGE_DIR .. py:data:: INDV_DATAPACKAGE_DIR .. py:data:: METADATA_DIR