Skip to content

brandonritchie/BigDataSafegraphTemplate

Repository files navigation

SafeGraph Semester Project

  1. Please read the Statement of Need that your team will need to leverage to write your work proposal.
  2. Use the team_repo template for your writeup and submission.
    • Please make sure your team repo is private.
    • You will need to share your repo with me, hathawayj, and the current semester team.
  3. Use this template repo to start your private repo within our organization. This repo will allow you to practice and share your personal work.
  4. Review the scripts in this repo and ensure you can handle the SafeGraph data. Within two weeks, we will have a coding challenge using SafeGraph data.

Scripts

The scripts in this template repository can help you get a picture of digesting the SafeGraph format.

This script depends on the Tidyverse and has two parsing functions at the top. There are some examples throughout the script of the issues with handling the SafeGraph data. The final dat_all object provides the full call that processes the data into a clean nested Tibble.

This script depends on the safegraph_functions.py file for some functions that can parse the nested dictionaries and lists within the POI. The Python functions create new data objects of the list and dictionary variables within the dataset.

API Examples

SafeGraph has an API to request data. We will use the API to build our datasets for use in Spark. We can figure out the API locally first.

An elementary API example of letting you evaluate that your system can make calls to a GraphQL API. It only uses the requests package in Python.

This script is the more extended and diverse example of using a GraphQL API. Specifically, it provides three examples of requesting data from the SafeGraph API.

Note the use of the following lines of code to store and retrieve our API key correctly. This code is also exemplified in create_environ.py script.

import os
from dotenv import load_dotenv

load_dotenv()
sfkey = os.environ.get("SAFEGRAPH_KEY")

We use three Python packages to get data from SafeGraph - gql, requests, and safegraphql. We elected to signal the start of each type of API request with the package imports spread throughout the script.

We will focus on the gql or requests examples for our work. I want to stay in gql.

This file creates .parquet files for upload for our cloud compute. In addition, it breaks all the nested data out into their own tables.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published