Skip to content

Instantly share code, notes, and snippets.

Created November 15, 2021 20:41
What would you like to do?
Calculates the paid transaction fees based on a CSV export from etherscan / bscan / polygonscan
require "csv"
if ! File.readable ARGV[0]
puts "I cannot read the file"
file =[0], "r")
data =
crypto_column = 10
fiat_column = 11
crypto = data[1..-1].inject([]) { |arr, line| arr << line[crypto_column].to_f }
fiat = data[1..-1].inject([]) { |arr, line| arr << line[fiat_column].to_f }
def print_stats title, arr
puts "#{title}"
puts "\tCount: #{arr.length}"
puts "\tSum: #{arr.sum}"
puts "\tMin: #{arr.min}"
puts "\tMax: #{arr.max}"
puts "\tAvg: #{arr.sum / arr.length.to_f}"
print_stats data[0][crypto_column], crypto
print_stats data[0][fiat_column], fiat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment