Overrides can delete entries by not specifying a replacement field.
This commit is contained in:
@@ -123,12 +123,16 @@ foreach ($lga_list as $lga) {
|
|||||||
$match_index = array_search($override['Match Field'], $header);
|
$match_index = array_search($override['Match Field'], $header);
|
||||||
$replace_index = array_search($override['Replace Field'], $header);
|
$replace_index = array_search($override['Replace Field'], $header);
|
||||||
if ($line[$match_index] === $override['Match Value']) {
|
if ($line[$match_index] === $override['Match Value']) {
|
||||||
$lines[$line_key][$replace_index] = $override['Replace Value'];
|
if ($replace_index !== false)
|
||||||
|
$lines[$line_key][$replace_index] = $override['Replace Value'];
|
||||||
|
else /* If 'Replace Field' is not matched - delete this entry */
|
||||||
|
$lines[$line_key]['Delete'] = 'y';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
|
if (isset($line['Delete'])) continue;
|
||||||
if (fputcsv($handle, $line) === FALSE) {
|
if (fputcsv($handle, $line) === FALSE) {
|
||||||
error_log('Error writing candidate to output file');
|
error_log('Error writing candidate to output file');
|
||||||
exit(3);
|
exit(3);
|
||||||
|
|||||||
Reference in New Issue
Block a user