Browse Source

qt history export: include fiat value in csv

3.3.3.1
SomberNight 6 years ago
parent
commit
436f6a4870
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 21
      electrum/gui/qt/history_list.py

21
electrum/gui/qt/history_list.py

@ -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:

Loading…
Cancel
Save