You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The program takes a `csv` file. It then uses the API key configured in config.yaml to start the processing of the addresses.
10
+
The program takes a `csv` file. It then uses the API key configured in `config.yaml` to start the processing of the addresses.
11
11
12
12
## Overview
13
13
@@ -20,23 +20,41 @@ You will need an API Key to call the Address Validation API.
20
20
21
21
Running modes are essentially different scenarios or use cases under which the software can be run. There are three running modes for the software which can all be configured using the config.yaml deescribed in the next section:
22
22
23
+
Details of the elements we discuss in this section can be found in the [validateAddress object reference guide](https://developers.google.com/maps/documentation/address-validation/reference/rest/v1/TopLevel/validateAddress)
24
+
23
25
1.### Test Mode : 1
24
26
25
-
In test mode you are allowed to store more details from the Address Validation API response (this can be configured from `main.py` in variable `header`).
27
+
In test mode you can store more details from the Address Validation API response .
28
+
29
+
- place_ID
30
+
- latlong
31
+
- formatted_address
32
+
- postal_address
33
+
- verdict
34
+
- address_type
35
+
- usps_data
36
+
- address_components
37
+
38
+
> **Note:** This is an extrmely permissive mode and should be avoided to be used for most scenarios. Only use case where this mode can be used is for testing and for very limited number of addresses. The responses have to be deleted within 15 days.
39
+
40
+
2.### Production mode -Users : 2 (default)
41
+
42
+
A Production mode <ins>not</ins> initiated after user/human interaction, only minimal data elements are allowed to be stored as per [Google Maps Platform Terms of Service](https://cloud.google.com/maps-platform/terms). Typically involves successive and multiple programmatic requests to Address Validation API.
26
43
27
-
2.### Production mode -NoUsers : 2 (default)
44
+
- place_ID
45
+
- latlong
46
+
- verdict
47
+
- address_components
28
48
29
-
a Production mode <ins>not</ins> initiated after user/human interaction, only minimal data elements are allowed to be stored as per [Google Maps Platform Terms of Service](https://cloud.google.com/maps-platform/terms). Typically involves successive and multiple programmatic requests to Address Validation API.
49
+
> **Note:** All the data elements in this mode can only be cached for a maximum of 30 days and > must be deleted afterwords.Only place_ID can be stored indefinitely.
30
50
31
-
3.### Production mode -Users : 3
51
+
3.### Production mode -NoUsers : 3
32
52
33
53
a Production mode initiated after user/human interaction, some more data may be cached for the unique purpose of the user completing his singular task.
34
54
35
-
* Update the mode in `config.yaml` file inside `/src` folder :
55
+
- place_ID
36
56
37
-
```
38
-
run_mode : 2
39
-
```
57
+
- Update the mode in `config.yaml` file:
40
58
41
59
### config.yaml
42
60
@@ -68,49 +86,29 @@ separator : ","
68
86
***Shelve db file:*** This is a temporary file created to maintain persistance for a long runninng process.
69
87
```shelve_db : addresses```
70
88
71
-
### Overall Flow of logic
72
-
73
-
* Reads a `csv` file
74
-
* Constructs the address as per configuration
75
-
* Stores the formatted addresses in a `shelve` object. This is done to make the program more resilient and async.
76
-
* The library then picks up addresses one by one from the `shelve` object and call the Address Validation API
77
-
* It gets the response back, parse it and store configured values back to the `shelve` object
78
-
* After all the addresses are inserted back to the datastructure, another piece of code executes and exports the data in a `csv` file
79
-
* Once the program is executed, it stores the [geocode](https://developers.google.com/maps/documentation/address-validation/requests-validate-address#response) and [`place ID`](https://developers.google.com/maps/documentation/places/web-service/place-id) against each given address and exports it in a `csv` file.
80
-
81
89
### Key features
82
90
83
-
* Maintains QPM limits set by the Address Validation API
84
-
* Async code and maintains state
85
-
* Checks for duplicates and runs repeated addresses only once
86
-
* Modes help create parity with Terms of Service
91
+
- Maintains QPM limits set by the Address Validation API
92
+
- Async code and maintains state
93
+
- Checks for duplicates and runs repeated addresses only once
94
+
- Generates a duplication report which shows which addresses are duplicated and how often
95
+
- Modes help create parity with Terms of Service
87
96
88
97
## Install and run
89
98
90
-
* Requires `python3` and `PyYAML`:
99
+
- Requires `python3` and `PyYAML`:
91
100
92
101
`brew install python3`
93
102
`brew install PyYAML`
94
103
95
-
* Install: python-high-volume-address-validation-library software also requires to have [google-maps-services-python](https://github.com/googlemaps/google-maps-services-python) installed, the latest version that includes Address Validation API:
104
+
- Install: python-high-volume-address-validation-library software also requires to have [google-maps-services-python](https://github.com/googlemaps/google-maps-services-python) installed, the latest version that includes Address Validation API:
96
105
`
97
106
pip3 install googlemaps
98
107
`
99
108
100
-
* Update `config.yaml` file in `/src` folder with your API key, `csv` output path, and mode in which to run the library (see "Running Modes" section):
101
-
102
-
```
103
-
## Address Validation API key
104
-
api_key : 'YOUR_API_KEY'
105
-
106
-
## Name of the output csv file
107
-
output_csv : './test-results.csv'
108
-
109
-
## There are three modes for running the software.
110
-
run_mode : 1
111
-
```
109
+
- Update `config.yaml` file in with your API key, `csv` output path, and mode in which to run the library (see "Running Modes" section):
112
110
113
-
* Run:
111
+
- Run:
114
112
`
115
113
python3 main.py
116
114
`
@@ -131,6 +129,37 @@ separator : ","
131
129
132
130
The software works in three modes. You can set the mode to comply with [Google Maps Platform Terms of Service](https://cloud.google.com/maps-platform/terms), by configuring the `config.yaml` file corresponding to the use case under which this is run.
133
131
132
+
### Overall Flow of logic
133
+
134
+
- Reads a `csv` file
135
+
- Constructs the address as per configuration
136
+
- Stores the formatted addresses in a `shelve` object. This is done to make the program more resilient and async.
137
+
- The library then picks up addresses one by one from the `shelve` object and call the Address Validation API
138
+
- It gets the response back, parse it and store configured values back to the `shelve` object
139
+
- After all the addresses are inserted back to the datastructure, another piece of code executes and exports the data in a `csv` file
140
+
- Once the program is executed, it stores the [geocode](https://developers.google.com/maps/documentation/address-validation/requests-validate-address#response) and [`place ID`](https://developers.google.com/maps/documentation/places/web-service/place-id) against each given address and exports it in a `csv` file.
141
+
134
142
## Output
135
143
136
144
This program outputs a CSV file. Based on the mode selected above, the contents of the CSV file changes.
145
+
146
+
It will also output a duplication csv file which reports all the addresses which were duplicates in the input request.
147
+
148
+
## License
149
+
150
+
Copyright 2022 Google LLC.
151
+
152
+
Licensed to the Apache Software Foundation (ASF) under one or more contributor
153
+
license agreements. See the NOTICE file distributed with this work for
154
+
additional information regarding copyright ownership. The ASF licenses this
155
+
file to you under the Apache License, Version 2.0 (the "License"); you may not
156
+
use this file except in compliance with the License. You may obtain a copy of
157
+
the License at
158
+
159
+
<http://www.apache.org/licenses/LICENSE-2.0>
160
+
161
+
Unless required by applicable law or agreed to in writing, software
162
+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
163
+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
164
+
License for the specific language governing permissions and limitations under
0 commit comments