lzakharov / csv2md

Command line tool for converting CSV files into Markdown tables.
MIT License
104 stars 8 forks source link

How to use it inside python? #10

Closed cherepashkin0 closed 2 years ago

cherepashkin0 commented 2 years ago

I'd like to use it inside python, without calling the prompt command. Is it possible?

cherepashkin0 commented 2 years ago

I mean, I'd like to write something like:

import csv2md
csv2md("file1.csv", "file2.md")
lzakharov commented 2 years ago

Yeap, you can use Table class to work with csv files:

from csv2md.table import Table

with open("input.csv") as f:
    table = Table.parse_csv(f)

print(table.markdown())