Community Data Science Workshops (Spring 2014)/Saturday May 3rd lecture

From OpenHatch wiki
Jump to navigation Jump to search

Lecture Outline

  1. Review material from last session
    • variables, different types
    • printing
    • if statements
    • lists
    • dictionaries
    • for loops
    • modules
    • example python program
  2. New programming concepts:
    • open a file and write to it
    • join a string together
    • interpolate variables into a string using % and %()s
    • from syntax for importing
    • urllib2 and urlopen
  3. JSON file (JavaScript Object Notation)
    • import json; json.loads()
    • like Python (except no single quotes)
    • simple lists, dictionaries
    • can reflect more complicated data structures
    • Example file at
  4. API
    • definition of an API in general
    • definition of web API for data
    • API that takes specially crafted URLs and gives appropriately sized picture of kittens
    • example of placekitten in browser
      • kittens of different sizes
      • kittens in greyscale or color
    • show how to use place
    • write a small program to grab arbitrary square from placekitten by asking for the size on standard in
  6. Wikipedia API
  7. Other APIs
    • every API is different, so read the documentation!
    • rate limiting
    • authenticaiton
    • text encoding issues