Improve handling of expected input file names in csv-normaliser

This commit is contained in:
2024-09-03 21:38:16 +10:00
parent 91978de573
commit 46bad101e0

View File

@@ -4,11 +4,13 @@ $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)) {
$lastpart = basename($folder); $expectedInputFileName = str_replace("-", " ", strtoupper(basename($folder))) . ".csv";
if (!isset($options['input'])) { if (!isset($options['input'])) {
$potentialInputFile = $folder . DIRECTORY_SEPARATOR . strtoupper($lastpart) . ".csv"; $expectedInputFile = $folder . DIRECTORY_SEPARATOR . $expectedInputFileName;
if (is_file($potentialInputFile)) { if (is_file($expectedInputFile)) {
$options['input'] = $potentialInputFile; $options['input'] = $expectedInputFile;
} else {
error_log("Couldn't find " . $expectedInputFile . "\n");
} }
} }
if (!isset($options['output'])) { if (!isset($options['output'])) {