a simpler tool for convert markdown table to polars
Project description
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.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mdpolars-0.1.0.tar.gz
(3.5 kB
view details)
Built Distribution
File details
Details for the file mdpolars-0.1.0.tar.gz
.
File metadata
- Download URL: mdpolars-0.1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.9.13 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 231a5038c5a167d87bfe0afe895919e08e035849b15bd8b90e23d2e654acb6f0 |
|
MD5 | 42046ff6516d41e262c5c7866b2c348f |
|
BLAKE2b-256 | cae6b245bcc997be8a3a085be73427633a34d4f4b365177bf648f7d9135610f2 |
File details
Details for the file mdpolars-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: mdpolars-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.9.13 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | afc4419bdb6faf7cf744e17c18cb1301db815dbc6144488f3b877014f69c7823 |
|
MD5 | a1dc70fdb3991a40e24e36a8c3969bad |
|
BLAKE2b-256 | f58ebb126e88d3f2079433d211d349df21c71fd32acf8b8a6df31c191f134219 |