From 01abb3ae71b579074ac1ec165da3dc6f86a4cdbc Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 29 Aug 2016 09:42:14 -0500 Subject: [PATCH] Add ability to print out the CSV headers --- speedtest.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/speedtest.py b/speedtest.py index 3e4ec8b..165abfd 100755 --- a/speedtest.py +++ b/speedtest.py @@ -1100,6 +1100,14 @@ def version(): sys.exit(0) +def csv_header(): + """Print the CSV Headers""" + + print_('Server ID,Sponsor,Server Name,Timestamp,Distance,Ping,Download,' + 'Upload') + sys.exit(0) + + def parse_args(): """Function to handle building and parsing of command line arguments""" description = ( @@ -1132,6 +1140,8 @@ def parse_args(): parser.add_argument('--csv-delimiter', default=',', type=PARSER_TYPE_STR, help='Single character delimiter to use in CSV ' 'output. Default ","') + parser.add_argument('--csv-header', action='store_true', default=False, + help='Print CSV headers') parser.add_argument('--json', action='store_true', default=False, help='Suppress verbose output, only show basic ' 'information in JSON format') @@ -1207,6 +1217,9 @@ def shell(): if args.version: version() + if args.csv_header: + csv_header() + if len(args.csv_delimiter) != 1: raise SystemExit('--csv-delimiter must be a single character')