Skip to content

Instantly share code, notes, and snippets.

@tonycoco
Created November 3, 2010 19:58
Show Gist options
  • Save tonycoco/661615 to your computer and use it in GitHub Desktop.
Save tonycoco/661615 to your computer and use it in GitHub Desktop.
A quick script to convert JMeter log XML files to CSV files for Excel imports (Since, Excel can't import XML data... wow.)
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
XML_FILE = ARGV[0]
CSV_FILE = ARGV[1]
if XML_FILE.nil? || CSV_FILE.nil?
puts 'usage: ruby jmeterxmltocsv.rb source_file target_file'
else
target_file = File.new(CSV_FILE, "w+")
xml_data = Nokogiri::XML(File.open(XML_FILE))
xml_data.xpath('//httpSample').each do |item|
arr = []
url = item.xpath('java.net.URL').first.content
arr << "\"#{url}\""
item.each do |k, v|
arr << v
end
target_file.puts(arr.join(','))
end
end
@jeremie-lesage
Copy link

Thanks for the script. Works like a charm.

For debian user, you must install nokogiri :

sudo aptitude install ruby-nokogiri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment