pytablewriter is a python library to write a table in various formats: CSV/HTML/JavaScript/JSON/Markdown/Excel/Pandas/Python/reStructuredText
import pytablewriter
writer = pytablewriter.MarkdownTableWriter()
writer.table_name = "zone"
writer.header_list = ["zone_id", "country_code", "zone_name"]
writer.value_matrix = [
["1", "AD", "Europe/Andorra"],
["2", "AE", "Asia/Dubai"],
["3", "AF", "Asia/Kabul"],
["4", "AG", "America/Antigua"],
["5", "AI", "America/Anguilla"],
]
writer.write_table()
# zone zone_id|country_code| zone_name ------:|------------|---------------- 1|AD |Europe/Andorra 2|AE |Asia/Dubai 3|AF |Asia/Kabul 4|AG |America/Antigua 5|AI |America/Anguilla
import pytablewriter
writer = pytablewriter.JavaScriptTableWriter()
writer.table_name = "zone"
writer.header_list = ["zone_id", "country_code", "zone_name"]
writer.value_matrix = [
["1", "AD", "Europe/Andorra"],
["2", "AE", "Asia/Dubai"],
["3", "AF", "Asia/Kabul"],
["4", "AG", "America/Antigua"],
["5", "AI", "America/Anguilla"],
]
writer.write_table()
var zone = [
["zone_id", "country_code", "zone_name"],
[1, "AD", "Europe/Andorra"],
[2, "AE", "Asia/Dubai"],
[3, "AF", "Asia/Kabul"],
[4, "AG", "America/Antigua"],
[5, "AI", "America/Anguilla"]
];
import pytablewriter
writer = pytablewriter.ExcelTableWriter()
writer.open_workbook("sample_single.xlsx")
writer.make_worksheet("zone")
writer.header_list = ["zone_id", "country_code", "zone_name"]
writer.value_matrix = [
["1", "AD", "Europe/Andorra"],
["2", "AE", "Asia/Dubai"],
["3", "AF", "Asia/Kabul"],
["4", "AG", "America/Antigua"],
["5", "AI", "America/Anguilla"],
]
writer.write_table()
writer.close()
More examples are available at http://pytablewriter.readthedocs.org/en/latest/pages/examples/index.html
pip install pytablewriter
Python 2.7+ or 3.3+