Skip to content

Commit

Permalink
Adding final support for MD, LaTeX
Browse files Browse the repository at this point in the history
  • Loading branch information
lcsrodriguez committed Jul 16, 2022
1 parent 9961bb0 commit dab3e2f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ If you choose the cloning method, please perform a prelinimary step: installing

| Class | Type | Description | Ok |
|-----------|-------------|--------------------------------------------------------------------------|:-----|
| Raw array | `list` | "Pure" Python array (list of lists) | |
| Raw array | `list` | "Pure" Python array (list of lists) | |
| Raw set | `set` | "Pure" Python set (set of lists) | |
| Raw dict | `dict` | "Pure" Python dict (dict of lists) | |
| Numpy | `ndarray` | Numpy n-dimensions array (for fast computations) (underlying C-layers) | |
| Numpy | `ndarray` | Numpy n-dimensions array (for fast computations) (underlying C-layers) | |
| Pandas | `Series` | Pandas Series conversion (for multiple signals, return a list of Series) | |
| Pandas | `DataFrame` | Pandas DataFrame conversion (best solution for further data processing) | |
| Pandas | `DataFrame` | Pandas DataFrame conversion (best solution for further data processing) | |
| HDFS | - | Hadoop Distributed File System (HDFS) *(using PyArrow)* | |
| RDD | - | Resilient Distributed Datasets (RDD) *(using PySpark)* | |

Expand Down
2 changes: 1 addition & 1 deletion headat/lib/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_export_types() -> list:
types supported by the tool's exporter
:return: list with specific types
"""
return [k for k in formats]
return list(formats.keys())


def get_export_extensions() -> list:
Expand Down
32 changes: 31 additions & 1 deletion headat/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def get_conversion_details(self, format: str = "csv") -> tuple:
raise TypeError("The format parameter needs to be represented as a non-empty string.")

format = format.lower()
if format not in get_export_extensions():
if format not in get_export_types():
raise ValueError("The format is not yet supported by the system. Please consider initiating a GitHub issue.")

print(f"Conversion to format : {format}")
Expand Down Expand Up @@ -289,6 +289,36 @@ def t_xml(self, **kwargs) -> bool:
except:
return False

def t_md(self, **kwargs) -> bool:
"""
Function converting the record to the MD (Markdown) 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("markdown")
cl_m = eval(f"df.{method}")
try:
cl_m(filename, **kwargs)
return True
except:
return False

def t_tex(self, **kwargs) -> bool:
"""
Function converting the record to the .tex (TeX) 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("latex")
cl_m = eval(f"df.{method}")
try:
cl_m(filename, **kwargs)
return True
except:
return False

# ----------------------------------------------------------------
# GENERIC METHODS

Expand Down
6 changes: 4 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
b = a.get_signals()
print(a.get_infos())
c = a.t_frame()

print(get_export_types())
a.t_csv()
a.t_xlsx()
a.t_json()
a.t_xml()
a.t_xml()
a.t_md()
a.t_tex()

0 comments on commit dab3e2f

Please sign in to comment.