Check multiple potential input filenames in csv-normaliser
This commit is contained in:
@@ -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'])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user