# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: county-scraping-env
#     language: python
#     name: county-scraping-env
# ---

import pandas as pd
import requests
import json
from datetime import date

# ## Get raw data from [map](https://csj.maps.arcgis.com/apps/webappviewer/index.html?appid=ddf8ba621416421ebd3fa5ebeeb5e684)
#
# app id = ddf8ba621416421ebd3fa5ebeeb5e684
#
# webmap id = ccacd1984a944111b23a2b5f00d1c3a2
#
# 7 datasets at https://services.arcgis.com/6kSayNlqm3HvsYZ8/ArcGIS/rest/services/EOC_COVID19_SantaClaraCountyFoodAccess/FeatureServer

# +
url = "https://services.arcgis.com/6kSayNlqm3HvsYZ8/ArcGIS/rest/services/EOC_COVID19_SantaClaraCountyFoodAccess/FeatureServer/%s/query"
dfs = []

params = {
    "f":"json",
    "where":"1=1",
    "returnGeometry":"true",
    "outFields":"*",
}

for id in range(1, 8):
  res = requests.get(url % id, params=params)
  df = pd.json_normalize(json.loads(res.text)['features'])
  dfs.append(df)
# -

raw_df = pd.concat(dfs)

today = date.today()
filename = 'santa_clara_raw_%s.csv' % (today.strftime("%m_%d_%Y"))
raw_df.to_csv(filename)



StarcoderdataJupyterScriptsDedupFiltered