Giter Site home page Giter Site logo

socrata_to_bigquery's Introduction

socrata_to_bigquery

This tool facilitates replicating Open Data from the Socrata Platform to Google BigQuery

WARNING: This is Alpha Release Software. It might be useful, but it will be rough around the edges

Many Governemnt Open-Data projects are hosted on Socrata, and searchable through the Open Data Network

Installing

go get github.com/jehiah/socrata_to_bigquery/...

Quick Start

  1. socrata_to_bigquery init

  2. socrata_to_bigquery download

  3. socrata_to_bigquery sync

Documentation

init

init initializes a yaml config file for synchronizing a Socrata dataset to BigQuery.

Usage: init -api-endpoint=https://path/to/api [-project-id -bq-dataset]

i.e. socrata_to_bigquery init -api-endpoint=https://data.cityofnewyork.us/resource/nc67-uf89 -data-dir=/path/to/data

API endpoint is the published Socrata API endpoint for a dataset.

This config file defines all fields that will be loaded to BigQuery, and the target bigquery project and dataset. Optionally it can defines custom conversion from TEXT socrata field to richer DATE or TIME field types. It also defines the target bigquery field names.

For example, this issue_date is a "text" format in Socrata but it will be parsed using the Go format string "01/02/2006" and stored in a DATE column. on_error = "SKIP_ROW" indicates that any rows that do not meet this date format will be skipped.

  [schema.issue_date]
    bigquery_type = "DATE"
    description = "Issue Date"
    # example_values = "\"03/06/2017\", \"10/07/2017\", \"05/29/2016\""

    # SKIP_VALUE | SKIP_ROW | ERROR 
    on_error = "SKIP_ROW"
    required = true
    source_field = "issue_date"
    source_field_type = "text"

    # the time.Parse format string
    time_format = "01/02/2006"
Usage of socrata_to_bigquery init:
  -api-endpoint string
    	The URL to the socrata dataset
  -bq-dataset string
    	BigQuery Dataset
  -data-dir string
    	directory to create config file in
  -debug
    	show debug output
  -filename string
    	defaults to ${NAME}-${ID}.toml
  -project-id string
    	Google Cloud Project ID
  -socrata-app-token string
    	Socrata App Token (also src SOCRATA_APP_TOKEN env)

download

Download does an initial copy from Socrata to Bigquery

Usage: socrata_to_bigquery download /path/to/config.yaml

i.e. socrata_to_bigquery download open-parking-and-camera-violations-nc67-uf89.toml

sync

Sync does a periodic copy of new records from Socrata to BigQuery copying only new records since the most recent record in BigQuery.

Usage: socrata_to_bigquery sync /path/to/config.yaml

i.e. socrata_to_bigquery sync open-parking-and-camera-violations-nc67-uf89.toml

Setup

Socrata API Token

https://dev.socrata.com/docs/authentication.html

export SOCRATA_APP_TOKEN=...

socrata_to_bigquery's People

Contributors

jehiah avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.