From: Dan White Date: Thu, 12 Apr 2018 19:07:36 +0000 (-0500) Subject: optional field separator for post-processing X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=1173f0c0a6cc3aa38785da021fad870cb806e68c;p=pubbin.git optional field separator for post-processing --- diff --git a/TimeSampleHistogram b/TimeSampleHistogram index 05a4262..c6c6ebd 100755 --- a/TimeSampleHistogram +++ b/TimeSampleHistogram @@ -52,6 +52,8 @@ parser.add_option('-b', '--bare', dest='bare', action='store_true', help='show histogram only', default=False) parser.add_option('-W', '--isoweek', dest='isoweek', help='only show ISO [YYYY-]WK', default=None) +parser.add_option('-f', '--field-sep', dest='sep', type='str', + help='field separator', metavar='f', default='') (opt, args) = parser.parse_args() #testing @@ -257,7 +259,10 @@ for k,v in sorted(hist.iteritems(), cmp=sorter): if len(k) > MAX_NAME_LEN: k = k[:MAX_NAME_LEN-1] + '~' - print ps % (k, v, '+'*tics(v)) + if opt.sep == '': + print ps % (k, v, '+'*tics(v)) + else: + print opt.sep.join((k, str(v))) if not opt.bare: print ('%%%is' % (name_len + count_len + 2)) % sum(hist.values())