Join two tables by address
A customer list and the orders, two suppliers' files, last year's export and this year's: the same places in different words and no common ID. A text join misses most of them; a join on the house does not.
What you have
Two CSV files with an address column each; the column of the second is named with --b-column:
customer,address C-17,"10 Rue de la Paix, Paris" C-18,"55 rue du Faubourg Saint-Honoré, 75008 Paris" C-19,"Paix, Lyon"
order,delivery_address O-901,10 rue de la paix 75002 Paris O-902,"10, Rue de la Paix, Paris" O-903,"8 Rue de la Masure, 95150 Taverny"
Steps
1. Pair the rows that are one house, and keep the rows without a pair:
$ gridpin match france.bin crm.csv orders.csv pairs.csv --b-column delivery_address --unmatched A 3 rows, B 3 rows: 2 pairs at house; without a pair A 2 (no_pair 1, weak 1), B 1 (no_pair 1); 0.0 s
2. Read the pairs:
$ cat pairs.csv
What you get
a_row | b_row | level | reason | a_address | b_address |
|---|---|---|---|---|---|
| 1 | 1 | house | 10 Rue de la Paix, Paris | 10 rue de la paix 75002 Paris | |
| 1 | 2 | house | 10 Rue de la Paix, Paris | 10, Rue de la Paix, Paris | |
| 2 | no_pair | 55 rue du Faubourg Saint-Honoré, 75008 Paris | |||
| 3 | weak | Paix, Lyon | |||
| 3 | no_pair | 8 Rue de la Masure, 95150 Taverny |
Customer 1 has two orders: both pair at the house, though one has a postcode and the other an extra comma. Paix, Lyon is too vague to name a house and says weak instead of pairing on a guess.
Why it works
Every row is answered by the country file, and its key is the town, street and house number of the answer. The two files are joined on that key, so a pair of large files costs two geocoding runs, not a comparison of every row with every other.
Limits
- In release 0.10.0
gridpin matchworks but is not yet listed bygridpin --help. - A house the file does not know cannot pair, even when both files write it the same way.
- Flats in one building are one house.
--level streetpairs by street instead, with every house of the street.
The function: join two tables by address. All its keys: command reference. Related: duplicates inside one list.