summaryrefslogtreecommitdiff
path: root/xml2json.rb
diff options
context:
space:
mode:
authorNat Lasseter <Nat Lasseter nathan@bytemark.co.uk>2018-04-10 16:44:18 +0100
committerNat Lasseter <Nat Lasseter nathan@bytemark.co.uk>2018-04-10 16:44:18 +0100
commitc41e90317b501bac16570995568e0bfd21d1e0b9 (patch)
tree2361b0f93bdfa10fba0e89ec353fa0e38d5f534e /xml2json.rb
parent3e8395b6d891c77d9c71d60b65d99861dc062f73 (diff)
renamed xport script
Diffstat (limited to 'xml2json.rb')
-rw-r--r--xml2json.rb51
1 files changed, 0 insertions, 51 deletions
diff --git a/xml2json.rb b/xml2json.rb
deleted file mode 100644
index aa1508d..0000000
--- a/xml2json.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require 'nokogiri'
-require 'json'
-
-FN = ARGV.shift.chomp
-
-doc = File.open("#{FN}.xml") { |f| Nokogiri::XML(f) }
-
-tstart = doc.css("xport>meta>start").text.to_i
-tstep = doc.css("xport>meta>step").text.to_i
-
-rcvd = []
-rmax = 0
-sent = []
-smax = 0
-
-doc.css("xport>data>row").each do |row|
- t = (row.css("t").text.to_i - tstart) / tstep
- r = row.css("v")[0].text.to_f
- s = row.css("v")[1].text.to_f
-
- rmax = r if r > rmax
- smax = s if s > smax
-
- rcvd << { t: t, v: r }
- sent << { t: t, v: s }
-end
-
-rmax *= 1.10
-smax *= 1.10
-
-rcvd.each do |r|
- r[:v] /= rmax
-end
-
-sent.each do |s|
- s[:v] /= smax
-end
-
-File.open("#{FN}.rcvd.json", "w") do |f|
- f.puts({
- max: rmax,
- data: rcvd
- }.to_json)
-end
-
-File.open("#{FN}.sent.json", "w") do |f|
- f.puts({
- max: smax,
- data: sent
- }.to_json)
-end