Improve handling of expected input file names in csv-normaliser
This commit is contained in:
@@ -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'])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user