Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ZogStriP committed Jan 6, 2025
1 parent 0234cb2 commit 7e5f471
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,28 @@
<title>watty.top</title>
<input id=file type=file accept=".zip" onchange="handleFiles(this.files)">
<script>
parseEDF = (csv) => {
console.log(csv);
to48 = (t) => {
if (t === "00:00:00") return 47;
const [h, m] = t.split(":").map(Number);
return (h * 2 + m / 30) - 1 | 0;
}

parse = (csv) => {
let data = {};
let day;

csv.split("\n").forEach((line) => {
const [a, b] = line.split(";");
if (a?.includes("/")) {
const [d, m, y] = a.split("/");
day = `${y}-${m}-${d}`;
data[day] = [];
} else if (a?.includes(":")) {
data[day][to48(a)] = b / 2;
}
});

console.log(data);
};

handleFiles = (files) => {
Expand All @@ -32,7 +52,7 @@
const name = td.decode(new Uint8Array(result, offset + 30, nameLength));
offset += 30 + nameLength + extraLength;
if (/^mes-puissances-atteintes-30min-\d+-\d+\.csv$/.test(name)) {
parseEDF(td.decode(new Uint8Array(result, offset, compressedSize)));
parse(td.decode(new Uint8Array(result, offset, compressedSize)));
break;
}
} else {
Expand Down

0 comments on commit 7e5f471

Please sign in to comment.