New export format: markdown
This commit is contained in:
+1
-1
@@ -43,7 +43,7 @@ pass_config = click.make_pass_decorator(Config)
|
||||
@click.option(
|
||||
"-f",
|
||||
"--format",
|
||||
type=click.Choice(["csv", "json", "excel", "html", "sqlite"]),
|
||||
type=click.Choice(["csv", "excel", "html", "json", "markdown", "sqlite"]),
|
||||
help="Output file format.",
|
||||
)
|
||||
@click.option("-z", "--zip", is_flag=True, help="Create ZIP archive.")
|
||||
|
||||
+17
-2
@@ -634,6 +634,21 @@ class Table(object):
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write(html_string)
|
||||
|
||||
def to_markdown(self, path, **kwargs):
|
||||
"""Writes Table to a Markdown file.
|
||||
|
||||
For kwargs, check :meth:`pandas.DataFrame.to_markdown`.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
path : str
|
||||
Output filepath.
|
||||
|
||||
"""
|
||||
md_string = self.df.to_markdown(**kwargs)
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write(md_string)
|
||||
|
||||
def to_sqlite(self, path, **kwargs):
|
||||
"""Writes Table to sqlite database.
|
||||
|
||||
@@ -715,7 +730,7 @@ class TableList(object):
|
||||
path : str
|
||||
Output filepath.
|
||||
f : str
|
||||
File format. Can be csv, json, excel, html and sqlite.
|
||||
File format. Can be csv, excel, html, json, markdown or sqlite.
|
||||
compress : bool
|
||||
Whether or not to add files to a ZIP archive.
|
||||
|
||||
@@ -728,7 +743,7 @@ class TableList(object):
|
||||
|
||||
kwargs = {"path": path, "dirname": dirname, "root": root, "ext": ext}
|
||||
|
||||
if f in ["csv", "json", "html"]:
|
||||
if f in ["csv", "html", "json", "markdown"]:
|
||||
self._write_file(f=f, **kwargs)
|
||||
if compress:
|
||||
self._compress_dir(**kwargs)
|
||||
|
||||
Reference in New Issue
Block a user