Example


In [14]:
json_string = '{"first_name": "Guido", "last_name":"Rossum"}'

In [15]:
import json
parsed_json = json.loads(json_string)

In [17]:
print(parsed_json['first_name'])


Guido

GA data


In [12]:
import json

#загрузить из json
with open('data/SKEIN_test.json') as file: #открываем файл на чтение
    input0 = json.load(file) #загружаем из файла данные в словарь data
print(input0)


{'error': False, 'data': {'reports': [{'data': {'maximums': [{'values': ['1030', '50']}], 'minimums': [{'values': ['1', '0']}], 'rows': [{'metrics': [{'values': ['1030', '50']}], 'dimensions': ['/']}, {'metrics': [{'values': ['20', '0']}], 'dimensions': ['/2017-data-technology-trends/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/7-easy-ways-to-make-your-webpage-sell-more-of-you-product/']}, {'metrics': [{'values': ['6', '0']}], 'dimensions': ['/careers./']}, {'metrics': [{'values': ['227', '0']}], 'dimensions': ['/careers/']}, {'metrics': [{'values': ['6', '0']}], 'dimensions': ['/Careers/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/careers~~pobj.']}, {'metrics': [{'values': ['101', '0']}], 'dimensions': ['/case-studies/']}, {'metrics': [{'values': ['26', '1']}], 'dimensions': ['/case-studies/c24tech-swift-blockchain/']}, {'metrics': [{'values': ['14', '0']}], 'dimensions': ['/case-studies/cools/']}, {'metrics': [{'values': ['21', '0']}], 'dimensions': ['/case-studies/toothscan-dental-app/']}, {'metrics': [{'values': ['13', '0']}], 'dimensions': ['/case-studies/tp-link-partner-portal/']}, {'metrics': [{'values': ['22', '1']}], 'dimensions': ['/case-studies/travel-weekly/']}, {'metrics': [{'values': ['8', '0']}], 'dimensions': ['/case-studies/we-are-models/']}, {'metrics': [{'values': ['11', '0']}], 'dimensions': ['/category/blog/']}, {'metrics': [{'values': ['2', '0']}], 'dimensions': ['/category/blog/dev-blog/']}, {'metrics': [{'values': ['2', '0']}], 'dimensions': ['/category/blog/lean-innovation-methodology/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/category/uncategorized/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/contact-kyiv/']}, {'metrics': [{'values': ['14', '3']}], 'dimensions': ['/contact-us/']}, {'metrics': [{'values': ['2', '0']}], 'dimensions': ['/development-for-technology-companies/']}, {'metrics': [{'values': ['16', '0']}], 'dimensions': ['/en_us/article/google-wins-legal-battle-against-pro-trump-spammer-over-the-letter-g']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/funding-for-high-growth-ventures/']}, {'metrics': [{'values': ['40', '0']}], 'dimensions': ['/google-liar-ru-spam-in-analytics/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/home']}, {'metrics': [{'values': ['2', '0']}], 'dimensions': ['/how-businesses-can-use-crowd-science/']}, {'metrics': [{'values': ['23', '0']}], 'dimensions': ['/incubator-rus/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/java-developer/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/jmb-app-is-now-available-in-appstore/']}, {'metrics': [{'values': ['2', '0']}], 'dimensions': ['/jobs/junior-software-developer-e-mail-support/']}, {'metrics': [{'values': ['2', '0']}], 'dimensions': ['/jobs/middle-python-developer/']}, {'metrics': [{'values': ['2', '0']}], 'dimensions': ['/jobs/office-manager-ceo-assistant/']}, {'metrics': [{'values': ['6', '1']}], 'dimensions': ['/jobs/project-manager-agile-pm-scrum-master/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/jobs/python-developer-new-york-company-project/']}, {'metrics': [{'values': ['4', '0']}], 'dimensions': ['/jobs/python-developer/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/jobs/react-js-developer-start-now/']}, {'metrics': [{'values': ['21', '1']}], 'dimensions': ['/jobs/ux-ui-designer/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/maxim-brovenko/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/new-exciting-market-niche-pre-travel-shopping/']}, {'metrics': [{'values': ['33', '0']}], 'dimensions': ['/news/google-g/']}, {'metrics': [{'values': ['3', '0']}], 'dimensions': ['/partner-portal-built-skein-wins-best-partner-programme-year/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/pavel-kozda/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/research-phase-tech-innovation-projects/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/shalaev-dmitriy/']}, {'metrics': [{'values': ['5', '0']}], 'dimensions': ['/skein-announces-release-igostories-project/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/skein-partnership-with-oil-industry/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/skein-presents-at-open-data-institute-summit/']}, {'metrics': [{'values': ['2', '0']}], 'dimensions': ['/startContent']}, {'metrics': [{'values': ['5', '0']}], 'dimensions': ['/svitlana-surodina/']}, {'metrics': [{'values': ['3', '0']}], 'dimensions': ['/technology-business-mentoring/']}, {'metrics': [{'values': ['2', '0']}], 'dimensions': ['/technology-consultancy-and-team-formation/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/terms-and-conditions/']}, {'metrics': [{'values': ['1', '0']}], 'dimensions': ['/ux']}, {'metrics': [{'values': ['21', '0']}], 'dimensions': ['/ux/']}, {'metrics': [{'values': ['14', '0']}], 'dimensions': ['/ux/ux-analysis-result/']}, {'metrics': [{'values': ['25', '0']}], 'dimensions': ['/what_we_do_lean_innovation/']}], 'isDataGolden': True, 'totals': [{'values': ['1775', '57']}], 'rowCount': 56}, 'columnHeader': {'metricHeader': {'metricHeaderEntries': [{'type': 'INTEGER', 'name': 'ga:sessions'}, {'type': 'INTEGER', 'name': 'ga:sessionsWithEvent'}]}, 'dimensions': ['ga:pagePath']}}]}, 'msg': 'Retrieve'}

In [29]:
print(input0("\"data\reports"))


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-29-bb0059b882af> in <module>()
----> 1 print(input0("\"data\reports"))

TypeError: 'dict' object is not callable

In [15]:
input1 = input0['data']
input1


Out[15]:
{'reports': [{'columnHeader': {'dimensions': ['ga:pagePath'],
    'metricHeader': {'metricHeaderEntries': [{'name': 'ga:sessions',
       'type': 'INTEGER'},
      {'name': 'ga:sessionsWithEvent', 'type': 'INTEGER'}]}},
   'data': {'isDataGolden': True,
    'maximums': [{'values': ['1030', '50']}],
    'minimums': [{'values': ['1', '0']}],
    'rowCount': 56,
    'rows': [{'dimensions': ['/'], 'metrics': [{'values': ['1030', '50']}]},
     {'dimensions': ['/2017-data-technology-trends/'],
      'metrics': [{'values': ['20', '0']}]},
     {'dimensions': ['/7-easy-ways-to-make-your-webpage-sell-more-of-you-product/'],
      'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/careers./'], 'metrics': [{'values': ['6', '0']}]},
     {'dimensions': ['/careers/'], 'metrics': [{'values': ['227', '0']}]},
     {'dimensions': ['/Careers/'], 'metrics': [{'values': ['6', '0']}]},
     {'dimensions': ['/careers~~pobj.'], 'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/case-studies/'], 'metrics': [{'values': ['101', '0']}]},
     {'dimensions': ['/case-studies/c24tech-swift-blockchain/'],
      'metrics': [{'values': ['26', '1']}]},
     {'dimensions': ['/case-studies/cools/'],
      'metrics': [{'values': ['14', '0']}]},
     {'dimensions': ['/case-studies/toothscan-dental-app/'],
      'metrics': [{'values': ['21', '0']}]},
     {'dimensions': ['/case-studies/tp-link-partner-portal/'],
      'metrics': [{'values': ['13', '0']}]},
     {'dimensions': ['/case-studies/travel-weekly/'],
      'metrics': [{'values': ['22', '1']}]},
     {'dimensions': ['/case-studies/we-are-models/'],
      'metrics': [{'values': ['8', '0']}]},
     {'dimensions': ['/category/blog/'], 'metrics': [{'values': ['11', '0']}]},
     {'dimensions': ['/category/blog/dev-blog/'],
      'metrics': [{'values': ['2', '0']}]},
     {'dimensions': ['/category/blog/lean-innovation-methodology/'],
      'metrics': [{'values': ['2', '0']}]},
     {'dimensions': ['/category/uncategorized/'],
      'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/contact-kyiv/'], 'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/contact-us/'], 'metrics': [{'values': ['14', '3']}]},
     {'dimensions': ['/development-for-technology-companies/'],
      'metrics': [{'values': ['2', '0']}]},
     {'dimensions': ['/en_us/article/google-wins-legal-battle-against-pro-trump-spammer-over-the-letter-g'],
      'metrics': [{'values': ['16', '0']}]},
     {'dimensions': ['/funding-for-high-growth-ventures/'],
      'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/google-liar-ru-spam-in-analytics/'],
      'metrics': [{'values': ['40', '0']}]},
     {'dimensions': ['/home'], 'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/how-businesses-can-use-crowd-science/'],
      'metrics': [{'values': ['2', '0']}]},
     {'dimensions': ['/incubator-rus/'], 'metrics': [{'values': ['23', '0']}]},
     {'dimensions': ['/java-developer/'], 'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/jmb-app-is-now-available-in-appstore/'],
      'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/jobs/junior-software-developer-e-mail-support/'],
      'metrics': [{'values': ['2', '0']}]},
     {'dimensions': ['/jobs/middle-python-developer/'],
      'metrics': [{'values': ['2', '0']}]},
     {'dimensions': ['/jobs/office-manager-ceo-assistant/'],
      'metrics': [{'values': ['2', '0']}]},
     {'dimensions': ['/jobs/project-manager-agile-pm-scrum-master/'],
      'metrics': [{'values': ['6', '1']}]},
     {'dimensions': ['/jobs/python-developer-new-york-company-project/'],
      'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/jobs/python-developer/'],
      'metrics': [{'values': ['4', '0']}]},
     {'dimensions': ['/jobs/react-js-developer-start-now/'],
      'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/jobs/ux-ui-designer/'],
      'metrics': [{'values': ['21', '1']}]},
     {'dimensions': ['/maxim-brovenko/'], 'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/new-exciting-market-niche-pre-travel-shopping/'],
      'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/news/google-g/'], 'metrics': [{'values': ['33', '0']}]},
     {'dimensions': ['/partner-portal-built-skein-wins-best-partner-programme-year/'],
      'metrics': [{'values': ['3', '0']}]},
     {'dimensions': ['/pavel-kozda/'], 'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/research-phase-tech-innovation-projects/'],
      'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/shalaev-dmitriy/'],
      'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/skein-announces-release-igostories-project/'],
      'metrics': [{'values': ['5', '0']}]},
     {'dimensions': ['/skein-partnership-with-oil-industry/'],
      'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/skein-presents-at-open-data-institute-summit/'],
      'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/startContent'], 'metrics': [{'values': ['2', '0']}]},
     {'dimensions': ['/svitlana-surodina/'],
      'metrics': [{'values': ['5', '0']}]},
     {'dimensions': ['/technology-business-mentoring/'],
      'metrics': [{'values': ['3', '0']}]},
     {'dimensions': ['/technology-consultancy-and-team-formation/'],
      'metrics': [{'values': ['2', '0']}]},
     {'dimensions': ['/terms-and-conditions/'],
      'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/ux'], 'metrics': [{'values': ['1', '0']}]},
     {'dimensions': ['/ux/'], 'metrics': [{'values': ['21', '0']}]},
     {'dimensions': ['/ux/ux-analysis-result/'],
      'metrics': [{'values': ['14', '0']}]},
     {'dimensions': ['/what_we_do_lean_innovation/'],
      'metrics': [{'values': ['25', '0']}]}],
    'totals': [{'values': ['1775', '57']}]}}]}

In [34]:
input2 = input1['reports']
a = {'a':1}
input2[0]['data']
#input2


Out[34]:
{'isDataGolden': True,
 'maximums': [{'values': ['1030', '50']}],
 'minimums': [{'values': ['1', '0']}],
 'rowCount': 56,
 'rows': [{'dimensions': ['/'], 'metrics': [{'values': ['1030', '50']}]},
  {'dimensions': ['/2017-data-technology-trends/'],
   'metrics': [{'values': ['20', '0']}]},
  {'dimensions': ['/7-easy-ways-to-make-your-webpage-sell-more-of-you-product/'],
   'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/careers./'], 'metrics': [{'values': ['6', '0']}]},
  {'dimensions': ['/careers/'], 'metrics': [{'values': ['227', '0']}]},
  {'dimensions': ['/Careers/'], 'metrics': [{'values': ['6', '0']}]},
  {'dimensions': ['/careers~~pobj.'], 'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/case-studies/'], 'metrics': [{'values': ['101', '0']}]},
  {'dimensions': ['/case-studies/c24tech-swift-blockchain/'],
   'metrics': [{'values': ['26', '1']}]},
  {'dimensions': ['/case-studies/cools/'],
   'metrics': [{'values': ['14', '0']}]},
  {'dimensions': ['/case-studies/toothscan-dental-app/'],
   'metrics': [{'values': ['21', '0']}]},
  {'dimensions': ['/case-studies/tp-link-partner-portal/'],
   'metrics': [{'values': ['13', '0']}]},
  {'dimensions': ['/case-studies/travel-weekly/'],
   'metrics': [{'values': ['22', '1']}]},
  {'dimensions': ['/case-studies/we-are-models/'],
   'metrics': [{'values': ['8', '0']}]},
  {'dimensions': ['/category/blog/'], 'metrics': [{'values': ['11', '0']}]},
  {'dimensions': ['/category/blog/dev-blog/'],
   'metrics': [{'values': ['2', '0']}]},
  {'dimensions': ['/category/blog/lean-innovation-methodology/'],
   'metrics': [{'values': ['2', '0']}]},
  {'dimensions': ['/category/uncategorized/'],
   'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/contact-kyiv/'], 'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/contact-us/'], 'metrics': [{'values': ['14', '3']}]},
  {'dimensions': ['/development-for-technology-companies/'],
   'metrics': [{'values': ['2', '0']}]},
  {'dimensions': ['/en_us/article/google-wins-legal-battle-against-pro-trump-spammer-over-the-letter-g'],
   'metrics': [{'values': ['16', '0']}]},
  {'dimensions': ['/funding-for-high-growth-ventures/'],
   'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/google-liar-ru-spam-in-analytics/'],
   'metrics': [{'values': ['40', '0']}]},
  {'dimensions': ['/home'], 'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/how-businesses-can-use-crowd-science/'],
   'metrics': [{'values': ['2', '0']}]},
  {'dimensions': ['/incubator-rus/'], 'metrics': [{'values': ['23', '0']}]},
  {'dimensions': ['/java-developer/'], 'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/jmb-app-is-now-available-in-appstore/'],
   'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/jobs/junior-software-developer-e-mail-support/'],
   'metrics': [{'values': ['2', '0']}]},
  {'dimensions': ['/jobs/middle-python-developer/'],
   'metrics': [{'values': ['2', '0']}]},
  {'dimensions': ['/jobs/office-manager-ceo-assistant/'],
   'metrics': [{'values': ['2', '0']}]},
  {'dimensions': ['/jobs/project-manager-agile-pm-scrum-master/'],
   'metrics': [{'values': ['6', '1']}]},
  {'dimensions': ['/jobs/python-developer-new-york-company-project/'],
   'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/jobs/python-developer/'],
   'metrics': [{'values': ['4', '0']}]},
  {'dimensions': ['/jobs/react-js-developer-start-now/'],
   'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/jobs/ux-ui-designer/'],
   'metrics': [{'values': ['21', '1']}]},
  {'dimensions': ['/maxim-brovenko/'], 'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/new-exciting-market-niche-pre-travel-shopping/'],
   'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/news/google-g/'], 'metrics': [{'values': ['33', '0']}]},
  {'dimensions': ['/partner-portal-built-skein-wins-best-partner-programme-year/'],
   'metrics': [{'values': ['3', '0']}]},
  {'dimensions': ['/pavel-kozda/'], 'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/research-phase-tech-innovation-projects/'],
   'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/shalaev-dmitriy/'], 'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/skein-announces-release-igostories-project/'],
   'metrics': [{'values': ['5', '0']}]},
  {'dimensions': ['/skein-partnership-with-oil-industry/'],
   'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/skein-presents-at-open-data-institute-summit/'],
   'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/startContent'], 'metrics': [{'values': ['2', '0']}]},
  {'dimensions': ['/svitlana-surodina/'], 'metrics': [{'values': ['5', '0']}]},
  {'dimensions': ['/technology-business-mentoring/'],
   'metrics': [{'values': ['3', '0']}]},
  {'dimensions': ['/technology-consultancy-and-team-formation/'],
   'metrics': [{'values': ['2', '0']}]},
  {'dimensions': ['/terms-and-conditions/'],
   'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/ux'], 'metrics': [{'values': ['1', '0']}]},
  {'dimensions': ['/ux/'], 'metrics': [{'values': ['21', '0']}]},
  {'dimensions': ['/ux/ux-analysis-result/'],
   'metrics': [{'values': ['14', '0']}]},
  {'dimensions': ['/what_we_do_lean_innovation/'],
   'metrics': [{'values': ['25', '0']}]}],
 'totals': [{'values': ['1775', '57']}]}

In [24]:
import pandas

init=pandas.read_json('data/SKEIN_test.json')
init


Out[24]:
data error msg
reports [{'data': {'maximums': [{'values': ['1030', '5... False Retrieve

In [8]:
data=init['data']
data


Out[8]:
reports    [{'data': {'maximums': [{'values': ['1030', '5...
Name: data, dtype: object

In [ ]: