Created
April 12, 2016 03:05
-
-
Save typpo/4fd0d020c227bd451fdd6f7912d97527 to your computer and use it in GitHub Desktop.
Export PersonalCapital view (with all filters) to CSV
This file contains 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
(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