diff --git a/csv-generic/parse_generic_csv.php b/csv-generic/parse_generic_csv.php index 8cb5ab8..0580fec 100644 --- a/csv-generic/parse_generic_csv.php +++ b/csv-generic/parse_generic_csv.php @@ -46,6 +46,7 @@ function match_lga(&$candidate_data, $lga_list) { foreach ($candidate_data as &$candidate) { /* Match user typed LGA/Ward to our database */ $max_score = 0; + $match_lga = null; foreach ($lga_list as $lga) { $aa = preg_split("/[^a-z]/", strtolower($candidate['Division'])); $bb = preg_split("/[^a-z]/", $lga['slug']); @@ -76,7 +77,11 @@ function match_lga(&$candidate_data, $lga_list) { } */ - $candidate['match_division'] = $match_lga['slug']; + if ($match_lga === null) { + $candidate['match_division'] = "no_match"; + } else { + $candidate['match_division'] = $match_lga['slug']; + } //$candidate['match_ward'] = $match_ward; } } diff --git a/get-generic.sh b/get-generic.sh index 6f68c0b..0512ed1 100755 --- a/get-generic.sh +++ b/get-generic.sh @@ -48,6 +48,11 @@ for key in $(jq -r 'keys[]' <<< $image_map) ; do esac lga=$(jq -r ".[\"$key\"][\"match_division\"]" <<< $image_map) + + if [ ! -d $"$DATA_PATH/$lga" ] ; then + continue + fi + dst="$DATA_PATH/$lga/$key$suffix" if [ -f $dst ] ; then