Skip to main content

mdpolars_py

a simple tool for convert markdown table to polars in python3. This tool is a lightweight tool for testing a code, so note that we are not validating the user's input.

pandas version is here

install

pip install mdpolars

usage

import polars as pl
import mdpolars

df = mdpolars.from_md("""
+------------+-------+
| id         | score |
+------------+-------+
| 1          | 15    |
| 2          | 11    |
| 3          | 11    |
| 4          | 20    |
+------------+-------+
""", schema=[("id", pl.Int64), ("score", pl.Int64)])

print(df)
# shape: (4, 2)
# ┌─────┬───────┐
# │ id  ┆ score │
# │ --- ┆ ---   │
# │ i64 ┆ i64   │
# ╞═════╪═══════╡
# │ 1   ┆ 15    │
# │ 2   ┆ 11    │
# │ 3   ┆ 11    │
# │ 4   ┆ 20    │
# └─────┴───────┘
# the header can be overwritten if the header exists
import mdpolars
df = mdpolars.from_md("""
+------------+-------+
| id         | score |
+------------+-------+
| 1          | 15    |
| 2          | 11    |
| 3          | 11    |
| 4          | 20    |
+------------+-------+
""", schema=["foo", "bar"])

# the default type is str.
print(df)
# shape: (4, 2)
# ┌─────┬─────┐
# │ foo ┆ bar │
# │ --- ┆ --- │
# │ str ┆ str │
# ╞═════╪═════╡
# │ 1   ┆ 15  │
# │ 2   ┆ 11  │
# │ 3   ┆ 11  │
# │ 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.

Metadata

Release files for mdpolars 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mdpolars 0.1.0
File Size Uploaded
mdpolars-0.1.0.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mdpolars 0.1.0
File Interpreter ABI Platform
mdpolars-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.6 kB

Release files / mdpolars-0.1.0.tar.gz

Download URL mdpolars-0.1.0.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
231a5038c5a167d87bfe0afe895919e08e035849b15bd8b90e23d2e654acb6f0
BLAKE2b-256 checksum
How to use checksums
cae6b245bcc997be8a3a085be73427633a34d4f4b365177bf648f7d9135610f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.9.13 Linux/6.2.0-1012-azure

Release files / mdpolars-0.1.0-py3-none-any.whl

Download URL mdpolars-0.1.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afc4419bdb6faf7cf744e17c18cb1301db815dbc6144488f3b877014f69c7823
BLAKE2b-256 checksum
How to use checksums
f58ebb126e88d3f2079433d211d349df21c71fd32acf8b8a6df31c191f134219
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.9.13 Linux/6.2.0-1012-azure

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page