Page 1 of 1

Places - Checking for Country

Posted: 06 Nov 2019 12:59
by quarlton
Every month I run a set of queries looking for various errors.
One of these checks that I have a valid Country in 'Places'.

Now because the country name could appear in any of 4 levels I need to check each of those places.
e.g.

Brazil
Essex, England
Liverpool, Lancashire, England
Beckside, Kirby Ireleth, Lancashire, England

So my query looks at all 'Places' but excludes those that have a valid country:

Exclude if =TextPart(%_PLAC%,1,1,STD)matches 'Australia'
Exclude if =TextPart(%_PLAC%,2,1,STD)matches 'Australia'
Exclude if =TextPart(%_PLAC%,3,1,STD)matches 'Australia'
Exclude if =TextPart(%_PLAC%,4,1,STD)matches 'Australia'


This is obviously repeated for every country that is in use.

The result is a list of 'Places' created without a Country name - or with a new one.

My existing query works fine, but I've just imported some new records with places missing country or have a previously unknown one, and I have to modify it and thought it may be right time to see if anyone had a better idea.

Many thanks

Re: Places - Checking for Country

Posted: 06 Nov 2019 14:18
by tatewise
You could make things a lot easier for yourself by making every Place use a fixed number of column parts.
In your case use Tools > Worth with Data > Places and use Columns button to set 4 column parts.
They would be designated something like Region, Town, County, Country.

Then reorganise each Place name to use 4 columns so your examples would become:
, , , Brazil
, , Essex, England
, Liverpool, Lancashire, England
Beckside, Kirby Ireleth, Lancashire, England

Those changes must be made in the Place records via the Places tab of the Records Window.
Or you could use the Rearrange Address and Place Parts Plugin and select the Right justify all Place parts option.
Don't worry about the extraneous blank columns as in most Diagrams and Reports they get tidied away.

Then in Tools > Worth with Data > Places it is easier to see if column 4 has a valid Country by sorting on that column.
If you wish to keep using your Query then it only needs one Row filter Expression per Country.

Just make sure all new records use the 4 column format, especially when importing from a GEDCOM, where you should correct the format before importing to your main Project.

Re: Places - Checking for Country

Posted: 06 Nov 2019 14:23
by Jane
I would assume the country should always be the last field in the place so you could simply use

Code: Select all

=TextPart(%_PLAC%,-1) matches 'Australia'
Which will return the last element. You then only need one line for each country.

Re: Places - Checking for Country

Posted: 06 Nov 2019 14:49
by quarlton
Mike, Jane

Many thanks for your quick responses.

Jane - Your solution to the query issue works fine and I have modified my query accordingly, thank you.

Mike - Your option also works very well, especially with the mass import, unfortunately for daily use it still relies on my data inputting skills, which is where the initial problem lies. :D I have some more data to import and will use your method for that.

Again, many thanks to you both.