Skip to content

Instantly share code, notes, and snippets.

@yuitest
Created May 5, 2014 13:37
Show Gist options
  • Save yuitest/ded937beda9b5cbc31bf to your computer and use it in GitHub Desktop.
Save yuitest/ded937beda9b5cbc31bf to your computer and use it in GitHub Desktop.
TSV を Markdown の表に
# 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