-
-
Notifications
You must be signed in to change notification settings - Fork 432
/
Copy pathcodebook.rst
90 lines (70 loc) · 2.47 KB
/
codebook.rst
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Codebook
========
Here you can download the complete codebook which details the variables that you can compute using the NeuroKit package.
.. raw:: html
<div style="text-align: center;">
<a href="_static/neurokit_codebook.csv" download="neurokit_codebook.csv">
<button style="background-color: #4CAF50; color: white; padding: 10px 20px; margin: 10px; border: none; cursor: pointer; width: 50%;">Download Codebook</button>
</a>
</div>
This codebook contains detailed descriptions of all variables, their descriptions, and additional metadata.
Codebook Table
==============
.. raw:: html
<style>
#csvDataTable {
width: 100%;
border-collapse: collapse;
.. background-color: #f8f8f8;
color: white;
}
#csvDataTable th, #csvDataTable td {
padding: 8px 12px;
border: 1px solid #ccc;
text-align: left;
}
</style>
<div id="csv-table">
<table id="csvDataTable">
</table>
</div>
<script>
function parseCSVLine(text) {
const cols = [];
let col = '';
let insideQuotes = false;
for (let i = 0; i < text.length; i++) {
const char = text[i];
if (insideQuotes && char === '"' && text[i + 1] == '"') {
i++;
col += char;
continue;
}
if (char === '"' && text[i - 1] !== '\\') {
insideQuotes = !insideQuotes;
continue;
}
if (char === ',' && !insideQuotes) {
cols.push(col);
col = '';
} else {
col += char;
}
}
cols.push(col);
return cols.map(field => field.replace(/""/g, '"')); // Replace escaped quotes
}
document.addEventListener("DOMContentLoaded", function() {
fetch('_static/neurokit_codebook.csv')
.then(response => response.text())
.then(csv => {
let lines = csv.trim().split('\n');
let html = '<tr><th>' + parseCSVLine(lines[0]).join('</th><th>') + '</th></tr>';
for (let i = 1; i < lines.length; i++) {
html += '<tr><td>' + parseCSVLine(lines[i]).join('</td><td>') + '</td></tr>';
}
document.getElementById('csvDataTable').innerHTML = html;
})
.catch(error => console.error('Error loading the CSV file:', error));
});
</script>