diff --git a/headat/lib/constants.py b/headat/lib/constants.py index 0b1fdfd..19d51f8 100644 --- a/headat/lib/constants.py +++ b/headat/lib/constants.py @@ -36,14 +36,14 @@ "method": "to_latex" }, "parquet": { - "extension": "pqt", + "extension": "parquet", "method": "to_parquet" }, "pickle": { - "extension": "pkl", + "extension": "pickle", "method": "to_pickle" }, - "sqlite": { + "sql": { "extension": "db", "method": "to_sql" }, diff --git a/headat/lib/functions.py b/headat/lib/functions.py index 3df9b61..b614559 100644 --- a/headat/lib/functions.py +++ b/headat/lib/functions.py @@ -1,6 +1,7 @@ from .constants import * import datetime import os +import scipy.io import warnings # Export routine to LaTeX generate a FutureWarning which has to be silenced warnings.simplefilter(action='ignore', category=FutureWarning) diff --git a/headat/main.py b/headat/main.py index c0726c1..21aac4c 100644 --- a/headat/main.py +++ b/headat/main.py @@ -319,6 +319,46 @@ def t_tex(self, **kwargs) -> bool: except: return False + def t_parquet(self, **kwargs) -> bool: + """ + Function converting the record to the Apache Parquet format + :rtype: bool + :return: Boolean set to True if conversion has been successfully performed + """ + # Gathering the details concerning the specified format + df, method, filename = self.get_conversion_details("parquet") + cl_m = eval(f"df.{method}") + try: + cl_m(filename, **kwargs) + return True + except: + return False + + def t_pickle(self, **kwargs) -> bool: + """ + Function converting the record to the Pickle (standard serialization) format + :rtype: bool + :return: Boolean set to True if conversion has been successfully performed + """ + # Gathering the details concerning the specified format + df, method, filename = self.get_conversion_details("pickle") + cl_m = eval(f"df.{method}") + try: + cl_m(filename, **kwargs) + return True + except: + return False + + def t_sql(self, **kwargs) -> bool: + """ + Function converting the record to a database format supported by SQLAlchemy + :rtype: bool + :return: Boolean set to True if conversion has been successfully performed + """ + # TODO + pass + + # ---------------------------------------------------------------- # GENERIC METHODS diff --git a/requirements.txt b/requirements.txt index ed8e787..9d7a774 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ openpyxl pyarrow tabulate -fastparquet \ No newline at end of file +fastparquet +SQLAlchemy \ No newline at end of file diff --git a/test.py b/test.py index beb5b7b..21f53a7 100644 --- a/test.py +++ b/test.py @@ -15,4 +15,6 @@ a.t_json() a.t_xml() a.t_md() -a.t_tex() \ No newline at end of file +a.t_tex() +a.t_parquet() +a.t_pickle() \ No newline at end of file