tsv to editable html table

pull/39/head
cneud 5 years ago
parent 03c56fe309
commit 2506639b46

@ -3,39 +3,48 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>ner.ed</title> <title>ner.ed</title>
<script type="text/javascript" src="https://unpkg.com/papaparse@latest/papaparse.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.0.1/papaparse.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<style> <style>
body{font-family:Courier;font-size:24px} body{font-family:Courier;font-size:24px}
th{}
tr{}
</style> </style>
</head> </head>
<body> <body>
<strong>ner.ed | simple editor for named entity recognition TSV</strong><br><br> <strong>ner.ed</strong><br><br>
<div id="table"></div> <table id="results">
<tbody></tbody>
</table>
<script> <script>
var data; var data;
function handleFileSelect(evt) { function handleFileSelect(evt) {
var file = evt.target.files[0]; var file = evt.target.files[0];
Papa.parse(file, { Papa.parse(file, {
header: true, header: true,
delimiter: '\t', delimiter: '\t',
comments: "#", comments: "#",
skipEmptyLines: true, skipEmptyLines: true,
dynamicTyping: true, dynamicTyping: true,
complete: function(results) { complete: function(results) {
console.log(results); console.log(results);
data = results; data = results;
} $.each(results.data, function(i, el) {
var row = $("<tr/>");
row.append($("<td/>").text(i));
$.each(el, function(i, cell) {
row.append($("<td/>").text(cell));
});
$("#table tbody").append(row);
});
}
});
}
$(document).ready(function() {
$("#tsv-file").change(handleFileSelect);
}); });
}
$(document).ready(function(){
$("#tsv-file").change(handleFileSelect);
});
</script> </script>
<input type="file" id="tsv-file" name="files"/> <input type="file" id="tsv-file" name="files"/>
</body> </body>

Loading…
Cancel
Save