JSFiddle - React, Tailwind, and code Playground
by guest271314
HTML
<pre>
</pre>
JavaScript
$(function () {
var url = "https://gist.githubusercontent.com/" + "guest271314/c4eebf14b4a3cfd36f58/" + "raw/37b82a07ec91e9f35396a23ee7aac26b8dd52c23/file.csv";
$.getJSON("https://query.yahooapis.com/v1/public/yql?q=select" + "* from csv where url='" + url + "?'" + "&format=json&diagnostics=true&callback=?")
.then(function (data, textStatus, jqxhr) {
var arr = [];
var len = data.query.count;
$.each(data.query.results.row, function (k, v) {
$.map(v, function (val) {
if (val === null) {
val = '""';
}
arr.push(val)
})
});
var rebuild_csv = function () {
$.when(
$("pre")
.append(
arr.splice(0, len).join(",") + "\r\n")).done(function () {
if (arr.length) {
rebuild_csv()
}
})
};
rebuild_csv()
}, function (jqxhr, textStatus, errorThrown) {
console.log(textStatus, errorThrown)
});
});