Compare commits

...

3 Commits

View File

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