Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Convert sample.jtl to csv
#! /usr/bin/env python
from xml.etree import ElementTree
from xml.sax.handler import ContentHandler
from xml.sax import parse
import csv
class Converter(ContentHandler):
def __init__(self, csv_filename):
self.output_file = open(csv_filename, 'w')
self.csv_writer = csv.DictWriter(self.output_file, ['lb','s', 'ec', 'hn', 'in', 'dt', 'by', 'na', 'ts', 'ng', 'tn', 'lt', 't', 'rc', 'sc', 'rm'])
def __del__(self):
def startDocument(self):
def startElement(self, name, attrs):
if name == 'httpSample':
adict = {}
for name in attrs.getNames():
adict[name] = attrs.getValue(name)
def main(filename):
parse(filename, Converter("%s.csv" % (filename)))
if __name__ == '__main__':
import sys
# print("\nUsage: %s input_file" % (sys.argv[0]))
# print("\n Input file should contain http samples created by JMeter in JTL format.\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment