Created
November 19, 2017 20:09
-
-
Save dallasmarlow/f26c66e73e524de5c125784b52d920cb to your computer and use it in GitHub Desktop.
etherscan sender summary
This file contains hidden or 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 'json' | |
# data src: | |
# https://etherscan.io/exportData?type=address&a=<addr> | |
abort 'usage: ./eth_summary.rb <from addr> <csv filename>' unless ARVG.size == 2 | |
address = ARGV.first | |
filename = ARGV.last | |
def process(input) | |
input.chomp.split(',').map {|k| k.gsub('"', '')} | |
end | |
entries = File.read(filename).lines | |
keys = process(entries.first) | |
summary = entries.last(entries.size - 1).reduce(Hash.new(0)) do |s, l| | |
entry = Hash[keys.zip(process(l))] | |
if entry['From'] == address | |
s['total'] += entry['Value_IN(ETH)'].to_f | |
s['transactions'] += 1 | |
end | |
s | |
end | |
puts summary.to_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment