Skip to content

Instantly share code, notes, and snippets.

@ioggstream
Created October 10, 2019 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ioggstream/3bf381912755fd5920091bd2cbcc4b94 to your computer and use it in GitHub Desktop.
Save ioggstream/3bf381912755fd5920091bd2cbcc4b94 to your computer and use it in GitHub Desktop.
Processa alcuni dati da dashboard.anpr.it
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#!/usr/bin/env python
from requests import get
url = "https://dashboard.anpr.it/api/dashboard/data.json"
data = get(u).json()
comuni_totali = [x['properties'] for x in d['geojson']['features']]
def ricerca_comune(label, comuni_totali):
return [x for x in comuni_totali if x['label'] == label.upper()]
# Mostra il comune di Milano
print(ricerca_comune('Milano', comuni_totali))
# Mostra il comune di Latina
print(ricerca_comune('Latina', comuni_totali))
# Mostra i comuni in presubentro
comuni_presubentro = [x for x in comuni_totali if 'data_presubentro' in x and 'data_subentro' not in x]
comuni_subentrati = [x for x in comuni_totali if 'data_subentro' in x]
comuni_inattivi = [x for x in comuni_totali if 'data_subentro' not in x and 'data_presubentro' not in x]
comuni_con_data_di_subentro_pianificata = [x for x in comuni_totali if 'prima_data_subentro' in x]
print("Ci sono %r comuni subentrati" % len(comuni_subentrati))
print("Ci sono %r comuni in presubentro di cui %r con data pianificata" % (len(comuni_presubentro), len(comuni_con_data_di_subentro_pianificata)))
print("Ci sono %r comuni inattivi" % len(comuni_inattivi))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment