Skip to content

Instantly share code, notes, and snippets.

@emailrhoads
Last active September 2, 2020 00:05
Show Gist options
  • Select an option

  • Save emailrhoads/50d1d711be800e08bb7ad9010213339b to your computer and use it in GitHub Desktop.

Select an option

Save emailrhoads/50d1d711be800e08bb7ad9010213339b to your computer and use it in GitHub Desktop.
[Export Mercury AVM results] #mercury
avm_r = ::Mercury::AvmResult.last(2500).map{ |r| r.slice('id', 'address_line_text', 'city_name', 'property_postal_code', 'property_state', 'result') }
results = avm_r.map do |r|
r.except('result') + {
'fsd' => r.dig('result','fsd'),
'valuation' => r.dig('result','valuation'),
'total_monthly_income_amount' => rand(1000..25000) # for CRAPE if you need
}
end
CSV.open("mercury_avm_results.tsv", "w", write_headers: true, headers: results.first.keys, col_sep: "\t") do |csv|
results.each do |h|
csv << h.values
end
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment