Hi Dies Thanks for the program. I'm modifying it for my needs
Andy -----Original Message----- From: Dies Koper [mailto:[EMAIL PROTECTED]] Sent: Thursday, September 12, 2002 3:59 AM To: JMeter Users List Subject: Re: Exporting data from jMeter Hi Andrew, > Has anyone got a way to export the data for example in the Aggregate Report. > I would like to be able to create a CSV (i.e. comma separated text) file > with this kind of information. I posted a message last week with my problem how to get the data into Excel to get similar graphs as JMeter shows. My problem was the order of the data, so I wrote a little program to fix it. Its output is a space separated file. You can easily change it to make it output comma separated files like you want them. Of course it would be great if JMeter could support the different formats. Regards, Dies /** * @(#)JMeterResultsToMatrix.java * * Explanation: converts JMeter's results file to space delimited ASCII record file * */ import java.util.*; import java.lang.String; import java.io.IOException; import java.io.FileWriter; import javax.xml.parsers.*; import org.xml.sax.*; import org.xml.sax.helpers.*; public class JMeterResultsToMatrix extends DefaultHandler { public String columnNames = ""; public String time = ""; public int maxColumns = 0; public int columnNo = 0; public FileWriter fileWriter = null; public void startElement(String uri, String localName, String qName, Attributes attributes) { String category; if (qName.equals("sampleResult")) { if (maxColumns == 0) { category = attributes.getValue("label"); if (columnNames.startsWith(category + " ")) { maxColumns = columnNo; // save line to file try { fileWriter.write(columnNames + "\n"); } catch (IOException e) { System.out.println("Error writing category names to file"); } } else { columnNames += category + " "; } } if (maxColumns != 0 && columnNo == maxColumns) { // save line to file try { fileWriter.write(time + "\n"); } catch (IOException e) { System.out.println("Error writing data to file"); } columnNo = 0; time = ""; } columnNo++; time += attributes.getValue("time") + " "; } } public void endElement(String uri, String localName, String qName) { } public static void main(String args[]) throws Exception { if (args.length != 1) { System.err.println("Supply infile as argument"); return; } JMeterResultsToMatrix handler = new JMeterResultsToMatrix(); SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser saxParser = factory.newSAXParser(); String outFilename = args[0].substring(0, args[0].lastIndexOf(".") + 1) + "txt"; handler.fileWriter = new FileWriter(outFilename); saxParser.parse(args[0], handler); try { handler.fileWriter.write(handler.time + "\n"); } catch (IOException e) { System.out.println("Error writing data to file"); } handler.fileWriter.close(); System.out.println("Finished parsing " + args[0] + ". Converted into " + outFilename); } } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

