Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98581

Re: Extracting and summing student scores from a JSON file using Python 2.7.10

From Pete Dowdell <contact@stridebird.com>
Newsgroups comp.lang.python
Subject Re: Extracting and summing student scores from a JSON file using Python 2.7.10
Date 2015-11-10 09:38 +0700
Message-ID <mailman.201.1447145509.16136.python-list@python.org> (permalink)
References <1d1610e5-d401-48f2-b5ee-3af91b9e485f@googlegroups.com> <mailman.194.1447115400.16136.python-list@python.org> <a5ad1e84-cd46-44b7-a7d4-ed0f9b74ec92@googlegroups.com>

Show all headers | View raw


On 10/11/15 08:12, Bernie Lazlo wrote:
> > > import json
> > >import urllib
> > >url ="http://www.wickson.net/geography_assignment.json"
> > >response = urllib.urlopen(url)
> > >data = json.loads(response.read())

All good up to data. Now:
# make a list of scores
scores = [d['score'] for d in data['comments']  if 
isinstance(d['score'], int) ]
# analysis
total_scores = sum(scores)
average_score= total_scores/float(len(scores))
min_score, max_score = min(scores), max(scores)

pd

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Extracting and summing student scores from a JSON file using Python 2.7.10 Bernie Lazlo <bjlazlo@gmail.com> - 2015-11-09 15:52 -0800
  Re: Extracting and summing student scores from a JSON file using Python 2.7.10 MRAB <python@mrabarnett.plus.com> - 2015-11-10 00:29 +0000
    Re: Extracting and summing student scores from a JSON file using Python 2.7.10 Bernie Lazlo <bjlazlo@gmail.com> - 2015-11-09 17:12 -0800
      Re: Extracting and summing student scores from a JSON file using Python 2.7.10 MRAB <python@mrabarnett.plus.com> - 2015-11-10 01:31 +0000
        Re: Extracting and summing student scores from a JSON file using Python 2.7.10 Bernie Lazlo <bjlazlo@gmail.com> - 2015-11-09 17:53 -0800
          Re: Extracting and summing student scores from a JSON file using Python 2.7.10 MRAB <python@mrabarnett.plus.com> - 2015-11-10 02:13 +0000
      Re: Extracting and summing student scores from a JSON file using Python 2.7.10 Pete Dowdell <contact@stridebird.com> - 2015-11-10 09:38 +0700
  Re: Extracting and summing student scores from a JSON file using Python 2.7.10 Bernie Lazlo <bjlazlo@gmail.com> - 2015-11-09 19:21 -0800
  Re: Extracting and summing student scores from a JSON file using Python 2.7.10 Denis McMahon <denismfmcmahon@gmail.com> - 2015-11-10 03:25 +0000
    Re: Extracting and summing student scores from a JSON file using Python 2.7.10 wayne.wickson@gmail.com - 2015-11-09 19:53 -0800
      Re: Extracting and summing student scores from a JSON file using Python 2.7.10 Bernie Lazlo <bjlazlo@gmail.com> - 2015-11-10 04:14 -0800
  Re: Extracting and summing student scores from a JSON file using Python 2.7.10 Bernie Lazlo <bjlazlo@gmail.com> - 2015-11-10 04:16 -0800

csiph-web