mplewis / csvtomd

📝📊 Convert your CSV files into Markdown tables.
MIT License
655 stars 90 forks source link

Document for using md_table directly in python #28

Open yytsui opened 5 years ago

yytsui commented 5 years ago

Although it's quite obvious by reading the source code, but it would be great to add a section like this in README.md:

from csvtomd import md_table

table_2d_array = [["First Name", "Last Name", "Location" , "Allegiance"],
["Mance", "Rayder", "North of the Wall",  "Wildlings"],
["Margaery", "Tyrell",  "The Reach",  "House Tyrell"],
["Danerys", "Targaryen",  "Meereen", "House Targaryen"],
["Tyrion", "Lannister",  "King's Landing",  "House Lannister"]]

md_table(table_2d_array)
"""
('First Name  |  Last Name  |  Location           |  Allegiance\n'
 '------------|-------------|---------------------|-----------------\n'
 'Mance       |  Rayder     |  North of the Wall  |  Wildlings\n'
 'Margaery    |  Tyrell     |  The Reach          |  House Tyrell\n'
 'Danerys     |  Targaryen  |  Meereen            |  House Targaryen\n'
 "Tyrion      |  Lannister  |  King's Landing     |  House Lannister")
"""

Because I have already spent that five minutes, other people don't have to.