Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

ca_counties.py 827 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  1. """California county shape files.
  2. https://data.ca.gov/dataset/ca-geographic-boundaries/resource/b0007416-a325-4777-9295-368ea6b710e6
  3. """
  4. import zipfile
  5. from invoke import run
  6. from loguru import logger
  7. from src.conf import settings
  8. RAW_DIR = settings.DATA_DIR / "raw/geography/"
  9. PROCESSED_DIR = settings.DATA_DIR / "processed/geography/"
  10. url = "https://data.ca.gov/dataset/e212e397-1277-4df3-8c22-40721b095f33/resource/b0007416-a325-4777-9295-368ea6b710e6/download/ca-county-boundaries.zip"
  11. fn = "ca-county-boundaries.zip"
  12. if __name__ == "__main__":
  13. # Get data
  14. RAW_DIR.mkdir(exist_ok=True)
  15. PROCESSED_DIR.mkdir(exist_ok=True)
  16. fp = RAW_DIR/fn
  17. # Download data
  18. cmd = f"curl -L {url} -o {fp}"
  19. run(cmd)
  20. # Unzip it!
  21. with zipfile.ZipFile(fp, "r") as fh:
  22. fh.extractall(PROCESSED_DIR)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...