In [1]:
import os, sys, io
import json
from pprint import pprint

import codecs

In [2]:
data_path = '../../data'

In [3]:
# Given the juristidction, file type and root path to data
# Returns a list of case ids in that jurisdiction
def get_cases_in_jurisdiction( juris_abv = 'nced', file_type = 'opinions', data_path = '../../data'):
    
    # path leading to the jurisdiction files
    path = data_path + '/'+ file_type + '/' + juris_abv + '/'
    
    # TODO: throw an exception
    # Check that the directory exists
    if not os.path.isdir(path):
        print 'not a legal path'
        return []
    else:
        return [int(f.split('.json')[0]) for f in os.listdir(path)]

In [4]:
nced_case_ids = get_cases_in_jurisdiction('nced')

In [37]:
def get_case_attributes(cl_file, op_file):
    print 'blah'

In [5]:
cl_file = data_path + '/clusters/nced/1361899.json'
op_file = data_path + '/opinions/nced/1361899.json'

In [17]:
# Open the cluster and opinion json files
with open(cl_file) as data_file:    
    cl_data_temp = json.load(data_file)
    
with open(op_file) as data_file:    
    op_data_temp = json.load(data_file)

# TODO: do this more succinctly
# Convert to utf8 from unicode
cl_data = {}
for k in cl_data_temp.keys():
    value = cl_data_temp[k]
    if type(value) == unicode:
        cl_data[k.encode('utf8')] = value.encode('utf8')
    else:
        cl_data[k.encode('utf8')] = value
        
        
op_data = {}
for k in op_data_temp.keys():
    value = op_data_temp[k]
    if type(value) == unicode:
        op_data[k.encode('utf8')] = value.encode('utf8')
    else:
        op_data[k.encode('utf8')] = value

In [22]:



Out[22]:
int

In [19]:
pprint(cl_data)


{'absolute_url': '/opinion/1361899/stott-v-martin/',
 'attorneys': '',
 'blocked': False,
 'case_name': 'Stott v. Martin',
 'case_name_full': '',
 'case_name_short': 'Stott',
 'citation_count': 5,
 'citation_id': 1334670,
 'date_blocked': None,
 'date_created': '2015-09-21T20:54:00.346234Z',
 'date_filed': '1992-02-12',
 'date_modified': '2016-03-03T19:38:36.416570Z',
 'docket': 'http://www.courtlistener.com/api/rest/v3/dockets/792608/',
 'federal_cite_one': '783 F. Supp. 970',
 'federal_cite_three': '',
 'federal_cite_two': '',
 'judges': 'Britt',
 'lexis_cite': '',
 'nature_of_suit': '',
 'neutral_cite': '',
 'non_participating_judges': [],
 'panel': [],
 'posture': '',
 'precedential_status': 'Published',
 'procedural_history': '',
 'resource_uri': 'http://www.courtlistener.com/api/rest/v3/clusters/1361899/',
 'scdb_decision_direction': None,
 'scdb_id': '',
 'scdb_votes_majority': None,
 'scdb_votes_minority': None,
 'scotus_early_cite': '',
 'slug': 'stott-v-martin',
 'source': 'L',
 'specialty_cite_one': '',
 'state_cite_one': '',
 'state_cite_regional': '',
 'state_cite_three': '',
 'state_cite_two': '',
 'sub_opinions': [u'http://www.courtlistener.com/api/rest/v3/opinions/1361899/'],
 'syllabus': '',
 'westlaw_cite': ''}

In [ ]: