Of course you also need totals per year, month, week, etc. Add a cumulative field to the export to keep track of the
wallet totals.
cumulative_value = 0
for t in w.transactions():
# Export this transaction as list of tuples in the following format:
# (in/out, transaction_hash, transaction_date, address, value)
te = t.export()
# Deduct fee from cumulative value if this is an outgoing transaction
if te[0][0] == 'out':
cumulative_value -= t.fee
# Loop through all transaction inputs and outputs
for tei in te:
# Create string with list of inputs addresses for incoming transactions, and outputs addresses for outgoing txs
addr_list = tei[3] if isinstance(tei[3], list) else [tei[3]]
if tei[0] == 'in':
cumulative_value += tei[4]
else:
cumulative_value -= tei[4]
# Print CSV string to standard output
print("%s,%s,%s,:%d,%d,%s" % (tei[0], tei[1], tei[2].strftime("%Y-%m-%d %H:%M:%S"), tei[4], cumulative_value,
";".join(list(set(addr_list)))))
in,7722a3c7bd0934522767564943e92a22caaca69e05eec9fbce23fe0a98f044f0,2019-11-19 13:37:10,:1000000,1000000,2MzRww85sARtDjHJ7QPUL1BdAx8y1Y1d3be;2NDkRVM4VAbrEoJtafq6pkV4hDQBBbsnAgA
in,00c76570c0eb91dfd3c644f6321db4de8e0983d2d0528276abeb08aaae9979a8,2019-11-19 13:56:32,:1000000,2000000,2NDBrFwt5J9JtvtEJGrbR1x3HMwY7eYQFXM
in,9fbc417ea3bcd8bd076bbac7a481dc7852c8e168173c70955a97e830cd93fab4,2019-11-19 14:23:35,:10000,2010000,
in,eff479895812039b2f4bcea508989bd3498df1595afc028570323a79f21d8693,2019-11-19 14:23:35,:7700,2017700,2NGAfMrvWZBnUx6wu3SMwRArBmMyNV9xXB9
in,7af39e591a11962cedf6f433f657670d5f0335663788035d9dbe8c0cb7209fb4,2019-11-19 14:23:35,:4000,2021700,2N5BVu3mnXieaREwFHVE4RKVBUTT79GFugx
out,913011f2fab73c230131501570a9f9d2ada5569fe79c9af0268947c9ddf0c2d2,2019-11-19 14:42:09,:41283,1980066,mkHS9ne12qx9pS9VojpwU5xtRd4T7X7ZUt
out,d3a43c327b25b884191ed1aefb39f67463d2d0a61ba0485dfeef1afb26cb8261,2019-11-19 14:42:09,:21645,1957381,mv4rnyY3Su5gjcDNzbMLKBQkBicCtHUtFB
out,cedd18dc60a87fd39a2c8b4ad6b15442b5a53faf5363bca18a36a305294a3f0f,2019-11-19 14:42:09,:36655,1919686,n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi
out,8b7ada2e6acd6619a080b25991f5d9408ee0b42a6a1ecc0eea304c4345a244b4,2019-11-19 14:42:09,:35153,1883508,2NGZrVvZG92qGYqzTLjCAewvPZ7JE8S8VxE
out,80333162a87bc8e088eaa54f1f6718c0b7caa72a29a2dfe15a8233110f01612d,2019-11-19 15:25:01,:302642,1579964,2NGZrVvZG92qGYqzTLjCAewvPZ7JE8S8VxE
out,449432de51fbe0b5b52a7234b2c860229ca3995888e87dd541a7885211838cc8,2019-11-19 15:25:01,:462332,1117281,mkHS9ne12qx9pS9VojpwU5xtRd4T7X7ZUt
out,9a22ec2e22518678cd6bf4ca88e23c3b7480482be579479ee6db49fbe53f42f7,2019-11-19 15:25:01,:250795,865571,mv4rnyY3Su5gjcDNzbMLKBQkBicCtHUtFB
out,796f4c1eec2a242508bcb75b1c57920597d376e381289804255d51d9e8c3b336,2019-11-19 15:25:01,:25579,839848,n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi
out,0335d2d56ac5861f8854c7539a9ffcbedc86c274a1603c605b5690a17968ba2f,2019-11-19 15:25:01,:120464,718482,2NGZrVvZG92qGYqzTLjCAewvPZ7JE8S8VxE
out,d3f512ad2ee829cdb8365adfee8afe73700dd2be8706b5542de302bab448df4f,2019-11-19 16:50:01,:286279,431342,2NGZrVvZG92qGYqzTLjCAewvPZ7JE8S8VxE
out,5714845c10f0cdf4f4767ebb5b00a05fc8428d4c1a35c4f2f11779353193a8f3,2019-11-19 16:51:31,:16375,414823,mv4rnyY3Su5gjcDNzbMLKBQkBicCtHUtFB