Skip to content

Instantly share code, notes, and snippets.

@Heavyblade
Created October 4, 2019 15:49
Show Gist options
  • Save Heavyblade/d9cf6354772f03086ae9bf45cd9a751d to your computer and use it in GitHub Desktop.
Save Heavyblade/d9cf6354772f03086ae9bf45cd9a751d to your computer and use it in GitHub Desktop.
def result_to_csv(name, result)
values = result.map { |x| x[:values] }
csv = [values.first.keys]
values.each { |x| csv << x.values }
csv_string = csv.map { |x| x.join(";") }.join("\n")
file = File.open(name, "w")
file.write(csv_string)
file.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment