var table = csv2table(csv);
function csv2table(text) {
var rows = text.split("\n");
var table = document.createElement("table");
for ( var i = 0; i < rows.length; i++ ) {
var tr = document.createElement("tr");
var tds = rows[i].split(",");
for ( var j = 0; j < tds.length; j++ ) {
var td = document.createElement(i == 0 ? "th" : "td");
td.innerHTML = tds[j];
tr.appendChild(td);
}
table.appendChild(tr);
}
return table.innerHTML;
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme