mdpolars


Namemdpolars JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/kyoto7250/mdpolars_py
Summarya simpler tool for convert markdown table to polars
upload_time2023-10-15 08:06:58
maintainer
docs_urlNone
authorkyoto7250
requires_python>=3.9,<4.0
licenseMIT
keywords polars markdown table test development
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://github.com/kyoto7250/mdpd)

## install
```bash
pip install mdpolars
```

## usage

```python
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    │
# └─────┴───────┘
```

```python
# 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

```markdown
| Syntax    | Description |
| --------- | ----------- |
| Header    | Title       |
| Paragraph | Text        |
```

```markdown
+------------+-------------+
| Syntax     | Description |
+------------+-------------+
| Header     | Title       |
| Paragraph  | Text        |
+------------+-------------+
```

```markdown
| Syntax    | Description |
| :-------- | ----------: |
| Header    | Title       |
| Paragraph | Text        |
```

```markdown
| 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kyoto7250/mdpolars_py",
    "name": "mdpolars",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "polars,markdown,table,test,development",
    "author": "kyoto7250",
    "author_email": "50972773+kyoto7250@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/ca/e6/b245bcc997be8a3a085be73427633a34d4f4b365177bf648f7d9135610f2/mdpolars-0.1.0.tar.gz",
    "platform": null,
    "description": "# mdpolars_py\na simple tool for convert markdown table to polars in python3.\nThis tool is a lightweight tool for testing a code, so note that we are not validating the user's input.\n\n[pandas version is here](https://github.com/kyoto7250/mdpd)\n\n## install\n```bash\npip install mdpolars\n```\n\n## usage\n\n```python\nimport polars as pl\nimport mdpolars\n\ndf = mdpolars.from_md(\"\"\"\n+------------+-------+\n| id         | score |\n+------------+-------+\n| 1          | 15    |\n| 2          | 11    |\n| 3          | 11    |\n| 4          | 20    |\n+------------+-------+\n\"\"\", schema=[(\"id\", pl.Int64), (\"score\", pl.Int64)])\n\nprint(df)\n# shape: (4, 2)\n# \u250c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n# \u2502 id  \u2506 score \u2502\n# \u2502 --- \u2506 ---   \u2502\n# \u2502 i64 \u2506 i64   \u2502\n# \u255e\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561\n# \u2502 1   \u2506 15    \u2502\n# \u2502 2   \u2506 11    \u2502\n# \u2502 3   \u2506 11    \u2502\n# \u2502 4   \u2506 20    \u2502\n# \u2514\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n```python\n# the header can be overwritten if the header exists\nimport mdpolars\ndf = mdpolars.from_md(\"\"\"\n+------------+-------+\n| id         | score |\n+------------+-------+\n| 1          | 15    |\n| 2          | 11    |\n| 3          | 11    |\n| 4          | 20    |\n+------------+-------+\n\"\"\", schema=[\"foo\", \"bar\"])\n\n# the default type is str.\nprint(df)\n# shape: (4, 2)\n# \u250c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2510\n# \u2502 foo \u2506 bar \u2502\n# \u2502 --- \u2506 --- \u2502\n# \u2502 str \u2506 str \u2502\n# \u255e\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2561\n# \u2502 1   \u2506 15  \u2502\n# \u2502 2   \u2506 11  \u2502\n# \u2502 3   \u2506 11  \u2502\n# \u2502 4   \u2506 20  \u2502\n# \u2514\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n\n## accepted table patterns\n\n```markdown\n| Syntax    | Description |\n| --------- | ----------- |\n| Header    | Title       |\n| Paragraph | Text        |\n```\n\n```markdown\n+------------+-------------+\n| Syntax     | Description |\n+------------+-------------+\n| Header     | Title       |\n| Paragraph  | Text        |\n+------------+-------------+\n```\n\n```markdown\n| Syntax    | Description |\n| :-------- | ----------: |\n| Header    | Title       |\n| Paragraph | Text        |\n```\n\n```markdown\n| Header    | Title       |\n| Paragraph | Text        |\n```\n\n## contribute\nIf you have suggestions for features or improvements to the code, please feel free to create an issue or PR.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "a simpler tool for convert markdown table to polars",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/kyoto7250/mdpolars_py",
        "Repository": "https://github.com/kyoto7250/mdpolars_py"
    },
    "split_keywords": [
        "polars",
        "markdown",
        "table",
        "test",
        "development"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f58ebb126e88d3f2079433d211d349df21c71fd32acf8b8a6df31c191f134219",
                "md5": "a1dc70fdb3991a40e24e36a8c3969bad",
                "sha256": "afc4419bdb6faf7cf744e17c18cb1301db815dbc6144488f3b877014f69c7823"
            },
            "downloads": -1,
            "filename": "mdpolars-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a1dc70fdb3991a40e24e36a8c3969bad",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 4100,
            "upload_time": "2023-10-15T08:06:56",
            "upload_time_iso_8601": "2023-10-15T08:06:56.428693Z",
            "url": "https://files.pythonhosted.org/packages/f5/8e/bb126e88d3f2079433d211d349df21c71fd32acf8b8a6df31c191f134219/mdpolars-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cae6b245bcc997be8a3a085be73427633a34d4f4b365177bf648f7d9135610f2",
                "md5": "42046ff6516d41e262c5c7866b2c348f",
                "sha256": "231a5038c5a167d87bfe0afe895919e08e035849b15bd8b90e23d2e654acb6f0"
            },
            "downloads": -1,
            "filename": "mdpolars-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "42046ff6516d41e262c5c7866b2c348f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 3485,
            "upload_time": "2023-10-15T08:06:58",
            "upload_time_iso_8601": "2023-10-15T08:06:58.292578Z",
            "url": "https://files.pythonhosted.org/packages/ca/e6/b245bcc997be8a3a085be73427633a34d4f4b365177bf648f7d9135610f2/mdpolars-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-15 08:06:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kyoto7250",
    "github_project": "mdpolars_py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "mdpolars"
}
        
Elapsed time: 0.14079s