aboutsummaryrefslogtreecommitdiffstats
path: root/tabletext.py
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2014-08-13 02:23:22 -0400
committerThibaut Horel <thibaut.horel@gmail.com>2014-08-13 02:25:09 -0400
commit780ccba33c8b4e71cea79baacac04e357da59f67 (patch)
tree52e1481a4d1c22c5f333d7f4e403b8dc98d6416a /tabletext.py
parent62376fce4b7940dd69925670124b13b5cbdcec34 (diff)
downloadtabletext-780ccba33c8b4e71cea79baacac04e357da59f67.tar.gz
Command line tool, add --sep option
Diffstat (limited to 'tabletext.py')
-rw-r--r--tabletext.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/tabletext.py b/tabletext.py
index 0e7ec09..c9412a4 100644
--- a/tabletext.py
+++ b/tabletext.py
@@ -111,6 +111,8 @@ def main():
parser.add_argument("--hcorners", help="corner characters for \
the header row", metavar="CHARS",
dest="header_corners", default="╒╤╕╞╪╡")
+ parser.add_argument("-s", "--sep", help="interpret CHAR as column\
+ separator in the input", metavar="CHAR", default=r"\t")
parser.add_argument("file", help="file to render or - to read from STDIN",
nargs="?", default="-", metavar="FILE")
parser.add_argument("--version", "-v", action="version",
@@ -121,10 +123,11 @@ def main():
args.file = sys.stdin
else:
args.file = open(args.file, encoding="utf-8")
-
- table = [line.strip().split("\t") for line in args.file.readlines()]
+ sep = args.sep.replace(r"\t", "\t")
+ table = [line.strip().split(sep) for line in args.file.readlines()]
args = vars(args)
del args["file"]
+ del args["sep"]
print_table(table, **args)
if __name__ == "__main__":