forked from privefl/rmarkdown-website-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
44 lines (42 loc) · 1.24 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<head>
<title>CSV to Table Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
</head>
<body>
<h1>Recent Publications</h1>
<table id="table">
<thead>
<tr>
<th>Author</th>
<th>Title</th>
<th>Year</th>
<th>Journal</th>
</tr>
</thead>
<tbody id="table-body">
</tbody>
</table>
<script>
Papa.parse("data.csv", {
download: true,
dynamicTyping: true,
header: true,
skipEmptyLines: true,
complete: function (results) {
const tableBody = document.getElementById("table-body");
results.data.forEach((row) => {
const author = row.Author;
const title = row.Title;
const year = row.Year;
const journal = row.Journal;
const newRow = document.createElement("tr");
newRow.innerHTML = `<td>${author}</td><td>${title}</td><td>${year}</td><td>${journal}</td>`;
tableBody.appendChild(newRow);
});
},
});
</script>
</body>
</html>