Data Representation - Day 2
Upcoming SlideShare
Loading in...5
×
 

Data Representation - Day 2

on

  • 526 views

Course notes for my ITP Data Representation Class. Probably not overly useful for people who didn't listen to the lecture.

Course notes for my ITP Data Representation Class. Probably not overly useful for people who didn't listen to the lecture.

Statistics

Views

Total Views
526
Views on SlideShare
526
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Data Representation - Day 2 Data Representation - Day 2 Presentation Transcript

  • Data Viz 101
  • 1. Get the data
  • 1. Get the data2. Parse the data into useful Objects
  • 1. Get the data2. Parse the data into useful Objects3. Render the objects on screen
  • 1. Get the data
  • CSV, JSON, XML
  • JSON XML CSV FlexibleStructured Easy
  • CSV (Comma-Separated Values) • Values (columns) are typically delimited by commas • Rows are typically delimited by carriage returns • Works for most data that can go in a simple spreadsheet • Not good for any kind of complex or relational data • Processing doesn’t have built in support for CSV but we can use JAVA libraries like opencsv
  • 4,14,26,17,98,35,128,362,9,18,45 dave,28,male,no erica,28,female,no roger,52,male,yes
  • XML (eXtensible Markup Language) • Data is stored in nested nodes • Structure of data is extremely flexible to define but not as flexible to change • Processing has built-in support for XML • Many APIs will return data in XML format
  • <patients> <patient name=”dave” age=28 gender=”male” smoker=”no”/> <patient name=”erica” age=28 gender=”female” smoker=”no”/> <patient name=”roger” age=52 gender=”male” smoker=”yes”/></patients>
  • JSON (JavaScript Object Notation) • Data is as JavaScript Objects • Extraordinarily flexible and lightweight • Lack of named structures can make stored data difficult to understand • JAVA and JavaScript do not play as nicely as you might think
  • { patients:[ {name:”dave”, age:28, gender:”male”, smoker:false}, {name:”erica”, age:28, gender:”female”, smoker:false}, {name:”roger”, age:52, gender:”male”, true} ]}
  • JSON JAVA
  • { Curly Braces - OBJECT};
  • [ Square Brackets - ARRAY ]
  • { name:”Peter”, age:18, smoker:false, friends:[“April”, “Ron”, “Valerie”]};
  • { name:”Peter”, age:18, smoker:false, friends:[“April”, “Ron”, “Valerie”]}; myJSONObject.age
  • { name:”Peter”, age:18, smoker:false, friends:[“April”, “Ron”, “Valerie”]}; myJSONObject.friends[1]
  • { name:”Peter”, age:18, smoker:false, friends:[“April”, “Ron”, “Valerie”]}; myJSONObject.getInt(“age”);
  • { name:”Peter”, age:18, smoker:false, friends:[“April”, “Ron”, “Valerie”] };JSONArray a = myJSONObject.getJSONArray[“friends”];a.getString(1);
  • myJSONObject = new JSONObject(stringData);JSONArray a = myJSONObject.getJSONArray[“friends”];println(a.getString(1));
  • try { myJSONObject = new JSONObject(stringData); JSONArray a = myJSONObject.getJSONArray[“friends”]; println(a.getString(1));} catch (Exception e) { println(“JSON LOAD FAILED.”);}
  • try { String url = “http://test.com/?getStuff”; String stringData = join(loadStrings(url), “”); myJSONObject = new JSONObject(stringData); JSONArray a = myJSONObject.getJSONArray[“friends”]; println(a.getString(1));} catch (Exception e) { println(“JSON LOAD FAILED.”);}
  • http://www.blprnt.com/processing/json.zip
  • Where’s the data?
  • 1. Find some data2. Ask some questions
  • 1. Ask some questions 2. Find some data
  • 3. Render the objects on screen
  • <insert wisdom here>
  • position size# colour rotation sound ?
  • position size# map() colour rotation sound ?
  • map(5,0,10,0,100) 50
  • map(5,0,10,0,1000) 500
  • map(5,0,10,20,30) 25