Kuehlung gefixt

This commit is contained in:
Carl Mahnke
2025-04-11 15:06:28 +02:00
parent 9d9e6f7786
commit 9b6b30ae30
3 changed files with 42 additions and 3 deletions

View File

@@ -0,0 +1,39 @@
import moment from "moment";
import { Enums, prisma } from "#lib/server/prisma.js";
import * as fs from "fs";
import { fileURLToPath } from "url";
import { hashPassword } from "#lib/password.js";
import Papa from "papaparse";
import { generatePrefixedId } from "#lib/db.js";
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
import { tryCatch } from "#lib/tryCatch.js";
import { createBrotliDecompress } from "zlib";
const path = fileURLToPath(new URL("./ausweise.csv.br", import.meta.url)); // .br for Brotli file
if (!fs.existsSync(path)) {
throw new Error(`${path} existiert nicht.`);
}
let i = 0;
const brotliStream = fs.createReadStream(path).pipe(createBrotliDecompress());
Papa.parse(brotliStream, {
header: true,
async complete(results, file) {
for (const dataset of results.data as any) {
const existing = await prisma.verbrauchsausweisWohnen.findFirst({
where: {
alte_ausweis_id: parseInt(dataset.id)
}
});
if (existing) {
continue;
}
console.log(dataset.id);
// do something with dataset...
}
},
});