Package json_to_relation :: Module edxTrackLogJSONParser :: Class EdXTrackLogJSONParser
[hide private]
[frames] | no frames]

Class EdXTrackLogJSONParser

source code

                           object --+    
                                    |    
generic_json_parser.GenericJSONParser --+
                                        |
                                       EdXTrackLogJSONParser

Parser specialized for EdX track logs.

Instance Methods [hide private]
 
__init__(self, jsonToRelationConverter)
Constructor
source code
[<any>]
processOneJSONObject(self, jsonStr, row)
Given one line from the EdX Track log, produce one row of relational output.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

    Inherited from generic_json_parser.GenericJSONParser
 
decArrayIndex(self, arrayIndexStack) source code
 
incArrayIndex(self, arrayIndexStack) source code
 
removeItemPartOfString(self, label)
Given a label, like employee.item.name, remove the last occurrence of 'item'
source code
 
setValInRow(self, theRow, colName, value)
Given a column name, a value and a partially filled row, add the column to the row, or set the value in an already existing row.
source code
Class Variables [hide private]
    Inherited from generic_json_parser.GenericJSONParser
  REMOVE_ITEM_FROM_STRING_PATTERN = re.compile(r'(item)\.([^\.]*...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, jsonToRelationConverter)
(Constructor)

source code 

Constructor

Parameters:
  • jsonToRelationConverter (JSONToRelation) - JSONToRelation instance
Overrides: object.__init__

processOneJSONObject(self, jsonStr, row)

source code 

Given one line from the EdX Track log, produce one row of relational output. Return is an array of values, the same that is passed in. On the way, the partne JSONToRelation object is called to ensure that JSON fields for which new columns have not been created yet receive a place in the row array. Different types of JSON records will be passed: server heartbeats, dashboard accesses, account creations, user logins. Example record for the latter:

"username": "", 
"host": "class.stanford.edu", 
"event_source": "server", 
"event_type": "/accounts/login", 
"time": "2013-06-14T00:31:57.661338", 
"ip": "98.230.189.66", 
"event": "{
           "POST": {}, 
           "GET": {
                "next": ["/courses/Medicine/HRP258/Statistics_in_Medicine/courseware/80160e.../"]}}", 
"agent": "Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20100101
Firefox/21.0", 
"page": null}
Parameters:
  • jsonStr (String) - string of a single, self contained JSON object
  • row (List<<any>>) - partially filled array of values. Passed by reference
Returns: [<any>]
the filled-in row
Overrides: generic_json_parser.GenericJSONParser.processOneJSONObject