Created
May 5, 2014 13:37
-
-
Save yuitest/ded937beda9b5cbc31bf to your computer and use it in GitHub Desktop.
TSV を Markdown の表に
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from __future__ import print_function, unicode_literals | |
import csv | |
import sys | |
def to_md(row): | |
return '|' + '|'.join(row) + '|' | |
cr = csv.reader(sys.stdin, delimiter=b'\t') | |
row = next(cr) # for header | |
print(to_md(row)) | |
print(to_md(('---',) * len(row))) | |
for row in cr: | |
print(to_md(row)) | |
# python table.py < heartbleed.csv > heartbleed.markdown |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment