Mercurial > hg > mirex-meta-analysis
view xml2txt.rb @ 2:624231da830b
Removed name from comments. Updated readme extensively. Renamed 2 files without significant changes. Added EP data as a bonus.
author | Jordan Smith <jordan.smith@eecs.qmul.ac.uk> |
---|---|
date | Fri, 20 Sep 2013 17:05:34 +0100 |
parents | |
children |
line wrap: on
line source
require 'xmlsimple' # Script to convert Ewald Peiszer's XML annotations to my TXT format annotations. a = XmlSimple.xml_in(ARGV[0]) rows = [] a["segmentation"][0]["segment"].each do |item| rows << [item["start_sec"],item["label"]].join("\t") end rows << [a["segmentation"][0]["segment"][-1]["end_sec"],"end"].join("\t") if ARGV[1].nil? then filename = ARGV[0].split(".")[0..-2].join(".") else filename = ARGV[1].chomp end c = File.open(filename+".txt",'w') c.write(rows) c.close