From 5fea265dc83346dc71a91b529e52945df14dbd31 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 13 May 2021 10:38:02 -0400 Subject: [PATCH] Change CSV to have unix style line endings The excel dialog has nice minimal quoting, but DOS line endings. Unix dialog has good line endings, but excessive quoting. Create a hybrid dialect and use it for nodesensors output. --- confluent_client/bin/nodesensors | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/confluent_client/bin/nodesensors b/confluent_client/bin/nodesensors index f9c544c6..3044a930 100755 --- a/confluent_client/bin/nodesensors +++ b/confluent_client/bin/nodesensors @@ -32,6 +32,13 @@ path = os.path.realpath(os.path.join(path, '..', 'lib', 'python')) if path.startswith('/opt'): sys.path.append(path) + +class hybridcsv(csv.excel): + lineterminator = '\n' + + +csv.register_dialect('hybrid', hybridcsv) + import confluent.client as client sensorcollections = { @@ -209,7 +216,7 @@ def main(): headernames.append(headername) if options.csv: linebyline = False - csvwriter = csv.writer(sys.stdout) + csvwriter = csv.writer(sys.stdout, dialect='hybrid') if options.interval: csvwriter.writerow(['time', 'node'] + headernames) else: