Skip to content

Instantly share code, notes, and snippets.

Created November 15, 2021 20:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save marek22k/af60f9cb529de592e41f599973a6f921 to your computer and use it in GitHub Desktop.
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