Easy Real Live Data for Your Processing-based Course!

41 views
Skip to first unread message

Nadeem Abdul Hamid

unread,
Jan 2, 2018, 8:49:30 PM1/2/18
to Processing Educators
Dear Processing educators,

If you are looking for an easy way to use data from online sources in your course assignments and projects, I invite you to consider Sinbad, a library intended to make it really easy to incorporate real, live data (directly off the Internet) in your course activities. A few quick demos of use are included at the bottom of this post.

To get started, the following project page has installation instructions, tutorials, quick usage reference, and a "bazaar" of data sources -- follow the links for "Java/Processing"...


The Sinbad library provides unified support for XML, JSON, and CSV/TSV data sources, handling of gzip and zip archives, automated caching facilities (useful for having offline access to data), and binding to instances of user-defined structures (see examples below). On top of all of that, a primary pedagogical goal has been to make the interface as simple and intuitive as possible for novice programmers.

If you decide to use the library, any and all (positive & negative) feedback, suggestions, insights, questions, etc. are greatly appreciated!

Best wishes,

nadeem

--
Nadeem Abdul Hamid
Associate Professor, Computer Science
Berry College, Mount Berry, GA 30149
http://cs.berry.edu/~nhamid/



-------------
 USAGE DEMOS
-------------

(To run each sketch below, download the "sinbad.jar" file from http://cs.berry.edu/sinbad/index-java.php and use the "Add File..." option from the Processing "Sketch" menu to incorporate the JAR file into your sketch.)

Example 1
---------

Consider the following program, which connects to the FAA live feed of airport status information (XML format):

    
    import core.data.*;
    
    DataSource faa;
    
    void setup() {
      DataSource.initializeProcessing(this);
      faa.setCacheTimeout(300);  // refresh every 5 minutes
    }
    
    void draw() {
      faa.load();
      // faa.printUsageString();   // uncomment to see available fields
    
      String name = faa.fetchString("Name");
      String state = faa.fetchString("State");
      String conditions = faa.fetchString("Weather/Weather");
      boolean delay = faa.fetchBoolean("Delay");
    
      println(name + " (" + state + "): " + conditions);
      if (delay) { 
        println("Flight delay");
      } else { 
        println("No delays");
      }
    
      noLoop();
    }


Example 2
---------

The following program connects to the USGS live feed of earthquake events (JSON format). Note that data is fetched directly as objects of a user-defined class:

    
    import core.data.*;
    
    DataSource Q;
    
    void setup() {
      DataSource.initializeProcessing(this);
    
      Q.setCacheTimeout(300);  // refresh every 5 minutes
    }
    
    void draw() {
      Q.load();
      // Q.printUsageString();  // uncomment to see available fields
    
      Quake aQuake = Q.fetch("Quake", "features/properties/place", "features/properties/time", 
        "features/properties/mag");
      println(aQuake);                                
    
      Quake[] todayQuakes = Q.fetchArray("Quake", "features/properties/place", "features/properties/time", 
        "features/properties/mag");
      println("Number of quakes today: " + todayQuakes.length);
      println(todayQuakes[ todayQuakes.length - 1 ]);
    
      noLoop();
    }
    
    
    class Quake {
      String location;
      long timestamp;
      double magnitude;
    
      public Quake(String location, long ts, double magnitude) {
        this.location = location;
        this.timestamp = ts;
        this.magnitude = magnitude;
      }
    
      public String toString() {
        return location + " | Magnitude: " + magnitude + " (" + timestamp + ")";
      }
    }


Example 3
---------

An example of a large data set (CSV + zip format). Again, the Sinbad library seamlessly unifies the data fields listed in the fetch call with the user-defined Auto class based on its constructor.


    import core.data.*;
    
    DataSource V;
    
    void setup() {
      DataSource.initializeProcessing(this);
    
      V.load();
      // V.printUsageString();  // uncomment to see available fields
    }
    
    void draw() {
    
      Auto one = V.fetch("Auto", "make", "model", "year", "trany", "city08", "highway08");
      println(one);
    
      ArrayList<Auto> allVehicles
        = V.fetchList("Auto", "make", "model", "year", "trany", "city08", "highway08");
      println(allVehicles.size());   // ~40,000 (!) of them...
    
      noLoop();
    }
    
    
    class Auto {
      String make;
      String model;
      int year;
      String transmission;
      double cityMPG;
      double hwyMPG;
    
      Auto(String make, String model, int year, String trans, 
           double cityMPG, double hwyMPG) {
        this.make = make;
        this.model = model;
        this.year = year;
        this.transmission = trans;
        this.cityMPG = cityMPG;
        this.hwyMPG = hwyMPG;
      }
    
      public String toString() {
        return make + " " + model + " (" + year + ", " + transmission + "): " +
          cityMPG + " mpg/city; " + hwyMPG + " mpg/highway";
      }
    }


Art Simon

unread,
Jan 2, 2018, 8:55:58 PM1/2/18
to Unname
Hey Nadeem,

I haven't checked out your work yet, but I just wanted to say thank you. This speaks to a real need in computer science education and I hope I can incorporate it into my AP CS Principles class where I use Processing and data analysis is definitely weak.

-- 
Art Simon
Computer Science Instructor
Lowell High School, San Francisco

margaret noble

unread,
Mar 12, 2021, 5:32:02 PM3/12/21
to Processing Educators
Hello Processing Educators,

I wanted to share a recent 12th-grade student project series from the winter quarter! This is an experimental, graphic arts project using Open Processing.






M A R G A R E T   N O B L E


Reply all
Reply to author
Forward
0 new messages