1
0

qt history export: include fiat value in csv

This commit is contained in:
SomberNight
2018-11-09 18:48:12 +01:00
parent 71ac3bb305
commit 436f6a4870

View File

@@ -414,26 +414,29 @@ class HistoryList(MyTreeWidget, AcceptFileDragDrop):
if not filename: if not filename:
return return
try: try:
self.do_export_history(self.wallet, filename, csv_button.isChecked()) self.do_export_history(filename, csv_button.isChecked())
except (IOError, os.error) as reason: except (IOError, os.error) as reason:
export_error_label = _("Electrum was unable to produce a transaction export.") export_error_label = _("Electrum was unable to produce a transaction export.")
self.parent.show_critical(export_error_label + "\n" + str(reason), title=_("Unable to export history")) self.parent.show_critical(export_error_label + "\n" + str(reason), title=_("Unable to export history"))
return return
self.parent.show_message(_("Your wallet history has been successfully exported.")) self.parent.show_message(_("Your wallet history has been successfully exported."))
def do_export_history(self, wallet, fileName, is_csv): def do_export_history(self, file_name, is_csv):
history = self.transactions history = self.transactions
lines = [] lines = []
for item in history: if is_csv:
if is_csv: for item in history:
lines.append([item['txid'], item.get('label', ''), item['confirmations'], item['value'], item['date']]) lines.append([item['txid'],
else: item.get('label', ''),
lines.append(item) item['confirmations'],
with open(fileName, "w+", encoding='utf-8') as f: item['value'],
item.get('fiat_value', ''),
item['date']])
with open(file_name, "w+", encoding='utf-8') as f:
if is_csv: if is_csv:
import csv import csv
transaction = csv.writer(f, lineterminator='\n') transaction = csv.writer(f, lineterminator='\n')
transaction.writerow(["transaction_hash","label", "confirmations", "value", "timestamp"]) transaction.writerow(["transaction_hash", "label", "confirmations", "value", "fiat_value", "timestamp"])
for line in lines: for line in lines:
transaction.writerow(line) transaction.writerow(line)
else: else: