Skip to content

Instantly share code, notes, and snippets.

@madpilot
Last active January 16, 2017 21:27
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 madpilot/31c5adb6963bc18bbcdbe876760cba99 to your computer and use it in GitHub Desktop.
Save madpilot/31c5adb6963bc18bbcdbe876760cba99 to your computer and use it in GitHub Desktop.
Normalize the LabNation export for my air conditioner, so each pulse is exactly 1.04
#!/usr/bin/env ruby -w
require 'csv'
file = ARGV[0]
out = file.split('.').join('-normalized.')
unless file
puts "Usage: normalize [filename]"
exit(1)
end
CSV.open(out, 'w') do |csv|
CSV.foreach(file) do |line|
ts = line[0].to_f
rounded = (ts - (ts % 1.04)).round(2)
csv << [ rounded, line[1] ]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment