Skip to main content

:clipboard: mdtable

PyPI License Code Style: Black Downloads

mdtable is a Python built command line interface that lets you convert csv files into Markdown formatted tables easily. It also provides a Python API to use for your projects.

Installation

Run pip install mdtable and check that the latest version is current installed by running mdtable —version.

Usage

>>> mdtable [OPTIONS] INPUT_FILE

The options available are:

-a, --aligns TEXT      Comma seperated list of 'l,r,c'
-p, --padding INTEGER  Padding for raw Markdown Table formatting
-s, --save TEXT        Path to save formatted markdown to
--delimiter TEXT       Delimiter character in csv
--quotechar TEXT       Quote character in csv
--escapechar TEXT      Escape character in csv
--writemode TEXT       Python write mode, e.g w+, w, a, a+
--version              Show the version and exit.
--help                 Show this message and exit.

Example:

Suppose you have a file input.csv like so:

Name,Department,Birthday Month
John Smith,Accounting,November
Erica Meyers,IT,March
Zain Patel,Engineering,June
Christopher Smith,Engineering,July
Kiseki Hirakawa,Human Resources,February

Running mdtable input.csv results in:

| Name              | Department      | Birthday Month |
| ----------------- | --------------- | -------------- |
| John Smith        | Accounting      | November       |
| Erica Meyers      | IT              | March          |
| Zain Patel        | Engineering     | June           |
| Christopher Smith | Engineering     | July           |
| Kiseki Hirakawa   | Human Resources | February       |

which looks like:

Name Department Birthday Month
John Smith Accounting November
Erica Meyers IT March
Zain Patel Engineering June
Christopher Smith Engineering July
Kiseki Hirakawa Human Resources February

API

[soon] more documentation

Example:

from mdtable import MDTable

markdown = MDTable('in.csv')
markdown_string_table = markdown.get_table()
markdown.save_table('out.csv')

Current Features

  • Ability to specify alignments, by providing a comma seperated string of alignments values (either 'l', 'r' or 'c') to mdtables —aligns [ALIGNS] INPUT_FILE, say for example mdtables —aligns c,c,l input.csv, there must be as many alignments characters as there are tables.

  • Ability to save output to a markdown file (and specify the writing mode) by providing the path to the file you wish to save to mdtables —save [SAVE_FILE] INPTUT_FILE say for example mdtables —save output.md input.csv

  • Provide custom delimiter, quotation and escape characters for reading in your csv file. This is done by providing the character to —delimiter, —quotechar, —escapehcar respectively.

  • Add a padding option to make table border padding customisable (in the raw output). This can now be done. Running mdtable input.csv -p 3 returns

    |   Name                |   Department        |   Birthday Month   |
    |   -----------------   |   ---------------   |   --------------   |
    |   John Smith          |   Accounting        |   November         |
    |   Erica Meyers        |   IT                |   March            |
    |   Zain Patel          |   Engineering       |   June             |
    |   Christopher Smith   |   Engineering       |   July             |
    |   Kiseki Hirakawa     |   Human Resources   |   February         |
    

Future Features

  • Implement a centering flag (for raw output) to prettify the output if required
  • Enable 0 padding
  • Add documentation for the API
  • Implement tests for delimeters``, quotechars and escapechars.

Release files for mdtable 0.2

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

Built distribution (wheel)

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

Release files / mdtable-0.2-py3-none-any.whl

Download URL mdtable-0.2-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c01e289ab3519fd13c8cd0c81db561fcfa1854696ef2148d2c99cd2854171610
BLAKE2b-256 checksum
How to use checksums
2e570f4b51601327dd318c287489e161a0463f13332e3d406cad79d239c67ad6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file

0.1

1 release file

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