RyotaBannai / mdpd

a simple tool for convert markdown table to pandas

Home Page:https://pypi.org/project/mdpd/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mdpd

mdpd is a simpler tool for convert markdown table to pandas. This tool is a lightweight tool for testing a code, so note that we are not validating the user's input.

install

pip install mdpd

usage

import mdpd

df = mdpd.from_md("""
+------------+-------+
| id         | score |
+------------+-------+
| 1          | 15    |
| 2          | 11    |
| 3          | 11    |
| 4          | 20    |
+------------+-------+
""")

print(df)
#   id score
# 0  1    15
# 1  2    11
# 2  3    11
# 3  4    20
# the header can be overwritten if the header exists
import mdpd
df = mdpd.from_md("""
| 1          | 15    |
| 2          | 11    |
| 3          | 11    |
| 4          | 20    |
""", header=["id", "score"])

print(df)
#   id score
# 0  1    15
# 1  2    11
# 2  3    11
# 3  4    20

accepted table patterns

| Syntax    | Description |
| --------- | ----------- |
| Header    | Title       |
| Paragraph | Text        |
+------------+-------------+
| Syntax     | Description |
+------------+-------------+
| Header     | Title       |
| Paragraph  | Text        |
+------------+-------------+
| Syntax    | Description |
| :-------- | ----------: |
| Header    | Title       |
| Paragraph | Text        |
| Header    | Title       |
| Paragraph | Text        |

contribute

If you have suggestions for features or improvements to the code, please feel free to create an issue or PR.

About

a simple tool for convert markdown table to pandas

https://pypi.org/project/mdpd/

License:MIT License


Languages

Language:Python 97.7%Language:Makefile 2.3%