Compare commits

...

3 Commits

View File

@@ -4,13 +4,15 @@ $options = getopt("", ["folder:", "input:", "output:", "media:"]);
if (isset($options['folder'])) { if (isset($options['folder'])) {
$folder = $options['folder']; $folder = $options['folder'];
if (is_dir($folder)) { if (is_dir($folder)) {
$expectedInputFileName = str_replace("-", " ", strtoupper(basename($folder))) . ".csv"; $expectedInputFileNames = [];
$expectedInputFileNames[] = str_replace("-", " ", strtoupper(basename($folder))) . ".csv";
$expectedInputFileNames[] = strtoupper(basename($folder)) . ".csv";
if (!isset($options['input'])) { if (!isset($options['input'])) {
$expectedInputFile = $folder . DIRECTORY_SEPARATOR . $expectedInputFileName; foreach ($expectedInputFileNames as $expectedInputFileName) {
if (is_file($expectedInputFile)) { $expectedInputFile = $folder . DIRECTORY_SEPARATOR . $expectedInputFileName;
$options['input'] = $expectedInputFile; if (is_file($expectedInputFile)) {
} else { $options['input'] = $expectedInputFile;
error_log("Couldn't find " . $expectedInputFile . "\n"); }
} }
} }
if (!isset($options['output'])) { if (!isset($options['output'])) {
@@ -84,14 +86,14 @@ if (($handle = fopen($inputFile, "r")) !== FALSE) {
$candidateName = trim($data[1]); $candidateName = trim($data[1]);
if ($candidateName == "example name") { if ($candidateName == "example name" || $candidateName == "") {
error_log("Skipping line ". $currentLine); error_log("Skipping line ". $currentLine);
continue; continue;
} }
//print("Adding candidate " . $candidateName . " to ". $currentWard . "\n"); //print("Adding candidate " . $candidateName . " to ". $currentWard . "\n");
$name_split = explode(" ", $data[1]); $name_split = explode(" ", str_replace("'", "_", $data[1]));
$name_patterns = [ $name_patterns = [
implode(".*", $name_split), implode(".*", $name_split),