Code Monkey home page Code Monkey logo

exsoda's Introduction

exsoda

What

This is a tiny wrapper for the socrata Soda2 open data API. It returns datasets as elixir streams for lazy evaluation.

usage

## Play around in the console

iex(1)> import Exsoda.Reader
iex(8)> with {:ok, stream} <- query("4tka-6guv", domain: "soda.demo.socrata.com") |> select([:region, :magnitude]) |> where("magnitude > 4.0") |> run do
...(8)>     Enum.take(stream, 2)
...(8)> end
[[{"Region", "south of the Fiji Islands"}, {"Magnitude", 4.6}],
 [{"Region", "Northern California"}, {"Magnitude", 4.4}]]


## Or elsewhere

result = query("4tka-6guv", )
|> select([:region, :magnitude])
|> where("magnitude > 4.0")
|> order("region")
|> offset(5)
|> run

with {:ok, row_stream} <- result do
  Enum.take(row_stream, 10)
  |> Enum.map(fn row ->
    IO.inspect row
  end)
end

# This will print something like the following to the console:
[{"Region", "0km SE of Sakai, Japan"}, {"Magnitude", 4.6}]
[{"Region", "0km SE of Sakai, Japan"}, {"Magnitude", 4.6}]
[{"Region", "0km SE of Sakai, Japan"}, {"Magnitude", 4.6}]
[{"Region", "0km SE of Sakai, Japan"}, {"Magnitude", 4.6}]
[{"Region", "0km SE of Sakai, Japan"}, {"Magnitude", 4.6}]
[{"Region", "100km E of Ile Hunter, New Caledonia"}, {"Magnitude", 5.6}]
[{"Region", "100km E of Ile Hunter, New Caledonia"}, {"Magnitude", 5.6}]
[{"Region", "100km E of Ile Hunter, New Caledonia"}, {"Magnitude", 5.6}]
[{"Region", "100km E of Ile Hunter, New Caledonia"}, {"Magnitude", 5.6}]
[{"Region", "100km E of Ile Hunter, New Caledonia"}, {"Magnitude", 5.6}]


Get a view

iex(1)> import Exsoda.Reader

iex(2)> query("hcnj-rei3", domain: "data.austintexas.gov") |> get_view

{:ok,
 %{"oid" => 12724312, "displayType" => "table",
   "publicationAppendEnabled" => false, ...}}

exsoda's People

Contributors

artempugachev avatar catstavi avatar chitang avatar michaelb990 avatar qmalcolm avatar rjmac avatar rozap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.