Last active
June 17, 2021 09:02
-
-
Save companje/4aa9d58b70ba172dd6a73c01e752770e to your computer and use it in GitHub Desktop.
PHP script voor conversie van CSV vanaf HetVolk.org naar volledige JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$rows = []; | |
if (($file = fopen($argv[1], "r")) !== FALSE) { | |
if (fgets($file, 4) !== "\xef\xbb\xbf") rewind($file); //Skip BOM if present | |
while (($data = fgetcsv($file, 0, ";", "\"" , "\\")) !== FALSE) { | |
$row = []; | |
$row["id"] = $data[0]; | |
$row["title"] = $data[1]; | |
$row["antwoord"] = json_decode($data[2]); | |
$rows[] = $row; | |
} | |
fclose($file); | |
} | |
echo(json_encode($rows,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); | |
?> |
en JSON_UNESCAPED_UNICODE encoding toegevoegd
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1000 aangepast naar 0 als parameter bij fgetcsv. de maximale lengte van een regel in de csv