Skip to content

Instantly share code, notes, and snippets.

@NerOcrO
Created July 16, 2025 07:06
Show Gist options
  • Save NerOcrO/a6658d42fc28f677393646b192729dcc to your computer and use it in GitHub Desktop.
Save NerOcrO/a6658d42fc28f677393646b192729dcc to your computer and use it in GitHub Desktop.
snippet
// parcourir un fichier csv via un champ d'upload
const formData = await request.formData()
const [diagnostiqueur] = formData.values() as FormDataIterator<File>
if (diagnostiqueur === undefined) {
return new Response("Bulk insert failed", { status: 200 })
}
const data = (await diagnostiqueur.text())
.split(/\r\n|\r|\n/)
.slice(1)
.filter((ligne): boolean => ligne !== "")
.map((ligne): Prisma.DiagnostiqueurCreateManyInput => {
const splitLine = ligne.split(";")
return {
nom: splitLine[0],
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment