Last active
August 29, 2015 13:56
-
-
Save jsdalton/8831277 to your computer and use it in GitHub Desktop.
Convert tabular data to YAMLular data.
This file contains 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
#!/usr/bin/env python | |
import sys | |
import argparse | |
parser = argparse.ArgumentParser(description='Convert tabular data to YAMLular data.') | |
parser.add_argument("-d", "--delimiter", help="delimiter to use (defaults to \\t)", default="\t") | |
args = parser.parse_args() | |
header = sys.stdin.readline().strip().split(args.delimiter) | |
for line in sys.stdin.readlines(): | |
print "-", | |
for k, v in zip(header, line.strip().split(args.delimiter)): | |
print "{0}: {1}".format(k, v) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment