Last active
March 7, 2017 08:47
-
-
Save ktaragorn/764aa15a4c0e185ac28ac2690749b660 to your computer and use it in GitHub Desktop.
parse wallet 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
var data = $("tbody tr").map(function(){ | |
var $row = $(this) | |
var category = $row.find(".record-category").text() | |
var date = $row.find("td:last-child .ng-binding").text().split(" ").join("").split("\n").join("") | |
var amount = $row.find(".nonreferential-amount span:last-child").text() | |
var currency = $row.find(".nonreferential-amount .currency-code").text() | |
var amount_sgd = $row.find(".negative-amount .record-amount").text() | |
var payment_type = $row.find("img.payment-icon").attr("title") | |
var description = $row.find(".record-note").text() | |
return [[category, description, amount, currency, amount_sgd, payment_type, date]] | |
}) | |
var csvContent = "data:text/csv;charset=utf-8,"; | |
Array.from(data).forEach(function(infoArray, index){ | |
dataString = "\"" + Array.from(infoArray).join("\",\"").replace("#", "") + "\""; | |
csvContent += index < data.length ? dataString+ "\n" : dataString; | |
}); | |
var encodedUri = encodeURI(csvContent); | |
window.open(encodedUri); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment