Adding Stab JMeter jmx
[appc/deployment.git] / JMeter / log_covert.py
diff --git a/JMeter/log_covert.py b/JMeter/log_covert.py
new file mode 100644 (file)
index 0000000..ec8478a
--- /dev/null
@@ -0,0 +1,59 @@
+#! /usr/bin/env python\r
+\r
+<!--\r
+============LICENSE_START==========================================\r
+ONAP : APPC\r
+===================================================================\r
+Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+===================================================================\r
+\r
+Unless otherwise specified, all software contained herein is licensed\r
+under the Apache License, Version 2.0 (the License);\r
+you may not use this software except in compliance with the License.\r
+You may obtain a copy of the License at\r
+\r
+    http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+Unless required by applicable law or agreed to in writing, software\r
+distributed under the License is distributed on an "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+See the License for the specific language governing permissions and\r
+limitations under the License.\r
+\r
+ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+============LICENSE_END============================================\r
+-->\r
+\r
+#### Command line arguments\r
+import argparse\r
+parser = argparse.ArgumentParser(description="Convert delimited file from one delimiter to another; defaults to converting pipe-delimited to CSV.")\r
+parser.add_argument("--delim-input", action="store", dest="delim_in", default="|", required=False, help="Input file delimiter; pipe is default (|)", nargs='?', metavar="'|'")\r
+parser.add_argument("--delim-output", action="store", dest="delim_out", default=",", required=False, help="Output file delimiter; comma is default (,)", nargs='?', metavar="','")\r
+parser.add_argument("--remove-line-char", action="store_true", dest="remove_line_char", default=False, help="remove \\n and \\r characters in fields and replace with spaces")\r
+parser.add_argument("--quote-char", action="store", dest="quote_char", default='"', required=False, help="quote character; defaults to double quote (\")", nargs='?', metavar="\"")\r
+parser.add_argument("-i", "--input", action="store", dest="input", required=False, help="input file; if not specified, take from standard input.", nargs='?', metavar="file.csv")\r
+parser.add_argument("-o", "--output", action="store", dest="output", required=False, help="output file; if not specified, write to standard output", nargs='?', metavar="file.pipe")\r
+parser.add_argument("-v", "--verbose", action="store_true", dest="verbose", default=False, help="increase verbosity")\r
+args  =  parser.parse_args()\r
+\r
+# Conversion for logs begins here.\r
+import argparse\r
+import csv\r
+import sys\r
+\r
+if args.input:\r
+    file_reader = file.reader(open(args.input, 'rb'), delimiter=args.dlm_in, quotechar=args.quote_char)\r
+else:\r
+    file_reader = file.reader(sys.stdin, delimiter=args.dlm_in, quotechar=args.quote_char)\r
+\r
+if args.output:\r
+    h_outfile = open(args.output, 'wb')\r
+else:\r
+    h_outfile = sys.stdout\r
+\r
+for row in file_reader:\r
+    row = args.dlm_out.join(row)\r
+    if args.remove_line_char:\r
+        row  =  row.replace('\n', ' ').replace('\r', ' ')\r
+    h_outfile.write("%s\n" % (row))\r
+    h_outfile.flush()
\ No newline at end of file