Handle more edge cases in csv-normaliser
This commit is contained in:
@@ -52,13 +52,13 @@ if (($handle = fopen($inputFile, "r")) !== FALSE) {
|
|||||||
$currentWard = "Coastal-Promontory";
|
$currentWard = "Coastal-Promontory";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($data[0] == "Candidate") {
|
if ($data[0] == "Candidate" || $data[0] == "") {
|
||||||
if ($currentWard == null) {
|
if ($currentWard == null) {
|
||||||
error_log("No ward found, skipping data on line " . $currentLine);
|
error_log("No ward found, skipping data on line " . $currentLine);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$candidateName = $data[1];
|
$candidateName = trim($data[1]);
|
||||||
|
|
||||||
if ($candidateName == " example name") {
|
if ($candidateName == " example name") {
|
||||||
error_log("Skipping line ". $currentLine);
|
error_log("Skipping line ". $currentLine);
|
||||||
@@ -89,12 +89,17 @@ if (($handle = fopen($inputFile, "r")) !== FALSE) {
|
|||||||
print("Failed to identify picture for " . $candidateName . "\n");
|
print("Failed to identify picture for " . $candidateName . "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$rating = $data[2];
|
||||||
|
if ($rating == "score" || $rating == "") {
|
||||||
|
$rating = 0;
|
||||||
|
}
|
||||||
|
|
||||||
array_push(
|
array_push(
|
||||||
$candidates,
|
$candidates,
|
||||||
[
|
[
|
||||||
"Ward" => $currentWard,
|
"Ward" => $currentWard,
|
||||||
"Candidate Name" => $candidateName,
|
"Candidate Name" => $candidateName,
|
||||||
"Rating" => $data[2],
|
"Rating" => $rating,
|
||||||
"Picture" => $picture
|
"Picture" => $picture
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user