Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@msonnabaum
Last active October 3, 2015 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msonnabaum/5c31bec95a4d2c8ddf53 to your computer and use it in GitHub Desktop.
Save msonnabaum/5c31bec95a4d2c8ddf53 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "csv"
def fix_dstat_csv(file)
dstat_csv = CSV.read file
# Shift off useless metadata rows
dstat_csv.shift 5
# dstat spreads the headers out over two rows, which R does not like, so
# combine them into one.
headers = dstat_csv[0].each_with_object([]) do |header, res|
res << "#{(header || res.last)}"
end
dstat_csv[1].map! {|header| "#{headers.shift}-#{header}"}
dstat_csv.shift
CSV do |csv|
dstat_csv.each {|row| csv << row}
end
end
fix_dstat_csv ARGV[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment