Calculates the paid transaction fees based on a CSV export from etherscan / bscan / polygonscan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "csv" | |
if ! File.readable ARGV[0] | |
puts "I cannot read the file" | |
end | |
file = CSV.open(ARGV[0], "r") | |
data = file.read | |
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}" | |
puts | |
end | |
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