Skip to content

Commit

Permalink
fix: disable number parsing in multi-type columns (#157)
Browse files Browse the repository at this point in the history
Try formatting a table with number parsing and formatting and, if mixed
types, retry with disabled number parsing.

Signed-off-by: Cesar Berrospi Ramis <75900930+ceberam@users.noreply.github.com>
  • Loading branch information
ceberam authored Jan 16, 2024
1 parent 192ef9c commit 667e7fc
Show file tree
Hide file tree
Showing 3 changed files with 67,569 additions and 4 deletions.
15 changes: 11 additions & 4 deletions deepsearch/documents/core/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,17 @@ def export_to_markdown(document: Dict[str, Any]) -> str:
table.append(tmp)

if len(table) > 1 and len(table[0]) > 0:

markdown_text += tabulate(
table[1:], headers=table[0], tablefmt="github"
)
try:
md_table = tabulate(table[1:], headers=table[0], tablefmt="github")
except ValueError:
md_table = tabulate(
table[1:],
headers=table[0],
tablefmt="github",
disable_numparse=True,
)

markdown_text += md_table
markdown_text += "\n\n"

return markdown_text
Loading

0 comments on commit 667e7fc

Please sign in to comment.