Skip to content

Instantly share code, notes, and snippets.

@typpo
Created April 12, 2016 03:05
Show Gist options
  • Save typpo/4fd0d020c227bd451fdd6f7912d97527 to your computer and use it in GitHub Desktop.
Save typpo/4fd0d020c227bd451fdd6f7912d97527 to your computer and use it in GitHub Desktop.
Export PersonalCapital view (with all filters) to CSV
(function() {
var data = angular.element(document.querySelector('.dataGrid')).scope().data;
var headers = ['Date', 'Account', 'Description', 'Category', 'Reimbursable', 'Amount'];
var csv = headers.join(',') + '\n';
data.forEach(function(data) {
var reimbursable = data._search_term.indexOf('reimbursable') > -1 ? 'REIMBURSABLE' : '';
fields = [data.transactionDate, data.accountName, data.description, data.category.name, reimbursable, data.value];
csv += fields.map(function(val) {
return '"' + val + '"';
}).join(',') + '\n';
});
var link = document.createElement('a');
link.setAttribute('href', 'data:attachment/csv,' + encodeURIComponent(csv));
link.setAttribute('download', 'personalcapital_export.csv');
link.click();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment