Skip to content

Instantly share code, notes, and snippets.

@mojowen
Created June 18, 2015 00:09
Show Gist options
  • Save mojowen/479586d70f8c54801a62 to your computer and use it in GitHub Desktop.
Save mojowen/479586d70f8c54801a62 to your computer and use it in GitHub Desktop.
Imports a CSV table of legacy stats
require 'csv'
raw = CSV.read('/tmp/pipeline_stat_table.csv')
labels = raw.shift
labels.delete('sample_id')
labels.delete('index')
data = raw.map{ |row| better = {}; labels.each_with_index{|k,i| v = row[i+2]; better[k] = v.index('.').nil? ? v.to_i : v.to_f }; [row.second, better] }
data.each{ |row| sample = Sample.find_by(name: row[0]); result = sample ? sample.results.first : nil; result ? (result.pipeline_metrics.update(row.second); result.save) : '' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment