Parsing a dictionary to get a value [closed] - python

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I have the following variable from,am trying to extract the revision value from it..does any one have any inputs on how this can be done?
u'revision': u'ad0beef66e5890cde6f0961ed03d8bc7e3defc63'
INPUT:-
data ={u'status': u'MERGED', u'topic': u'', u'currentPatchSet': {u'approvals': [{u'by': {u'username': u'lnxbuild', u'name': u'Linux Build Service Account', u'email': u'lnxbuild#localhost'}, u'type': u'CRVW', u'description': u'Code Review', u'value': u'2', u'grantedOn': 1360897100}, {u'type': u'SUBM', u'by': {u'username': u'lnxbuild', u'name': u'Linux Build Service Account', u'email': u'lnxbuild#localhost'}, u'value': u'1', u'grantedOn': 1360897100}, {u'by': {u'username': u'lnxbuild', u'name': u'Linux Build Service Account', u'email': u'lnxbuild#localhost'}, u'type': u'TEST', u'description': u'Developer Verified', u'value': u'1', u'grantedOn': 1360897100}, {u'by': {u'username': u'lnxbuild', u'name': u'Linux Build Service Account', u'email': u'lnxbuild#localhost'}, u'type': u'VRIF', u'description': u'Verified', u'value': u'1', u'grantedOn': 1360897100}], u'createdOn': 1360897100, u'number': u'1', u'parents': [u'354a90cd1ae4ba9ce2a2a4ad38f8efbc8c02b02d', u'e4ffc07a6f78210a49f6ad2e0d705d7054c20ed6'], u'uploader': {u'username': u'lnxbuild', u'name': u'Linux Build Service Account', u'email': u'lnxbuild#localhost'}, u'ref': u'refs/changes/52/249452/1', u'revision': u'ad0beef66e5890cde6f0961ed03d8bc7e3defc63'}, u'url': u'https://review-android.company.com/249452', u'createdOn': 1360897100, u'number': u'249452', u'lastUpdated': 1360897121, u'project': u'platform/vendor/qcom-proprietary/wlan', u'sortKey': u'00231d720003ce6c', u'branch': u'master', u'owner': {u'username': u'lnxbuild', u'name': u'Linux Build Service Account', u'email': u'lnxbuild#localhost'}, u'open': False, u'id': u'Iad0beef66e5890cde6f0961ed03d8bc7e3defc63', u'subject': u'Merge "wlan: Enable ActiveModeOffload by default"'}
OUTPUT:-
ad0beef66e5890cde6f0961ed03d8bc7e3defc63

Simply retrieve it by following the 'currentPatchSet' key then the 'revision' key
data['currentPatchSet']['revision']
Interactive example which shows how this works:
>>> import pprint # pretty print for seeing the layout of the dict
>>> data ={u'status': u'MERGED', u'topic': u'', u'currentPatchSet': {u'approvals': [{u'by': {u'username': u'lnxbuild', u'name': u'Linux Build Service Account', u'email': u'lnxbuild#localhost'}, u'type': u'CRVW', u'description': u'Code Review', u'value': u'2', u'grantedOn': 1360897100}, {u'type': u'SUBM', u'by': {u'username': u'lnxbuild', u'name': u'Linux Build Service Account', u'email': u'lnxbuild#localhost'}, u'value': u'1', u'grantedOn': 1360897100}, {u'by': {u'username': u'lnxbuild', u'name': u'Linux Build Service Account', u'email': u'lnxbuild#localhost'}, u'type': u'TEST', u'description': u'Developer Verified', u'value': u'1', u'grantedOn': 1360897100}, {u'by': {u'username': u'lnxbuild', u'name': u'Linux Build Service Account', u'email': u'lnxbuild#localhost'}, u'type': u'VRIF', u'description': u'Verified', u'value': u'1', u'grantedOn': 1360897100}], u'createdOn': 1360897100, u'number': u'1', u'parents': [u'354a90cd1ae4ba9ce2a2a4ad38f8efbc8c02b02d', u'e4ffc07a6f78210a49f6ad2e0d705d7054c20ed6'], u'uploader': {u'username': u'lnxbuild', u'name': u'Linux Build Service Account', u'email': u'lnxbuild#localhost'}, u'ref': u'refs/changes/52/249452/1', u'revision': u'ad0beef66e5890cde6f0961ed03d8bc7e3defc63'}, u'url': u'https://review-android.company.com/249452', u'createdOn': 1360897100, u'number': u'249452', u'lastUpdated': 1360897121, u'project': u'platform/vendor/qcom-proprietary/wlan', u'sortKey': u'00231d720003ce6c', u'branch': u'master', u'owner': {u'username': u'lnxbuild', u'name': u'Linux Build Service Account', u'email': u'lnxbuild#localhost'}, u'open': False, u'id': u'Iad0beef66e5890cde6f0961ed03d8bc7e3defc63', u'subject': u'Merge "wlan: Enable ActiveModeOffload by default"'}
Let's visualize the data
>>> pprint.pprint(data)
{u'branch': u'master',
u'createdOn': 1360897100,
u'currentPatchSet': {u'approvals': [{u'by': {u'email': u'lnxbuild#localhost',
u'name': u'Linux Build Service Account',
u'username': u'lnxbuild'},
u'description': u'Code Review',
u'grantedOn': 1360897100,
u'type': u'CRVW',
u'value': u'2'},
{u'by': {u'email': u'lnxbuild#localhost',
u'name': u'Linux Build Service Account',
u'username': u'lnxbuild'},
u'grantedOn': 1360897100,
u'type': u'SUBM',
u'value': u'1'},
{u'by': {u'email': u'lnxbuild#localhost',
u'name': u'Linux Build Service Account',
u'username': u'lnxbuild'},
u'description': u'Developer Verified',
u'grantedOn': 1360897100,
u'type': u'TEST',
u'value': u'1'},
{u'by': {u'email': u'lnxbuild#localhost',
u'name': u'Linux Build Service Account',
u'username': u'lnxbuild'},
u'description': u'Verified',
u'grantedOn': 1360897100,
u'type': u'VRIF',
u'value': u'1'}],
u'createdOn': 1360897100,
u'number': u'1',
u'parents': [u'354a90cd1ae4ba9ce2a2a4ad38f8efbc8c02b02d',
u'e4ffc07a6f78210a49f6ad2e0d705d7054c20ed6'],
u'ref': u'refs/changes/52/249452/1',
u'revision': u'ad0beef66e5890cde6f0961ed03d8bc7e3defc63',
u'uploader': {u'email': u'lnxbuild#localhost',
u'name': u'Linux Build Service Account',
u'username': u'lnxbuild'}},
u'id': u'Iad0beef66e5890cde6f0961ed03d8bc7e3defc63',
u'lastUpdated': 1360897121,
u'number': u'249452',
u'open': False,
u'owner': {u'email': u'lnxbuild#localhost',
u'name': u'Linux Build Service Account',
u'username': u'lnxbuild'},
u'project': u'platform/vendor/qcom-proprietary/wlan',
u'sortKey': u'00231d720003ce6c',
u'status': u'MERGED',
u'subject': u'Merge "wlan: Enable ActiveModeOffload by default"',
u'topic': u'',
u'url': u'https://review-android.company.com/249452'}
So the revision appears to be in the currentPatchSet dictionary:
>>> pprint.pprint(data['currentPatchSet'])
{u'approvals': [{u'by': {u'email': u'lnxbuild#localhost',
u'name': u'Linux Build Service Account',
u'username': u'lnxbuild'},
u'description': u'Code Review',
u'grantedOn': 1360897100,
u'type': u'CRVW',
u'value': u'2'},
{u'by': {u'email': u'lnxbuild#localhost',
u'name': u'Linux Build Service Account',
u'username': u'lnxbuild'},
u'grantedOn': 1360897100,
u'type': u'SUBM',
u'value': u'1'},
{u'by': {u'email': u'lnxbuild#localhost',
u'name': u'Linux Build Service Account',
u'username': u'lnxbuild'},
u'description': u'Developer Verified',
u'grantedOn': 1360897100,
u'type': u'TEST',
u'value': u'1'},
{u'by': {u'email': u'lnxbuild#localhost',
u'name': u'Linux Build Service Account',
u'username': u'lnxbuild'},
u'description': u'Verified',
u'grantedOn': 1360897100,
u'type': u'VRIF',
u'value': u'1'}],
u'createdOn': 1360897100,
u'number': u'1',
u'parents': [u'354a90cd1ae4ba9ce2a2a4ad38f8efbc8c02b02d',
u'e4ffc07a6f78210a49f6ad2e0d705d7054c20ed6'],
u'ref': u'refs/changes/52/249452/1',
u'revision': u'ad0beef66e5890cde6f0961ed03d8bc7e3defc63',
u'uploader': {u'email': u'lnxbuild#localhost',
u'name': u'Linux Build Service Account',
u'username': u'lnxbuild'}}
Indeed it is, under the 'revision' key. We retrieve it:
>>> print data['currentPatchSet']['revision']
ad0beef66e5890cde6f0961ed03d8bc7e3defc63
>>>

Related

How do I flat a Nested Json file in Python?

I have a nested Json file with arrays.
I want to flat it so there won't be nested Jsons.
For example:
Code for Json:
https://jsonblob.com/4b255e51-7e9f-11e8-b89c-37203846213e
This Json has sub-Json and also array that contains Json.
The source is:
Output should be:
If there are arrays that contains a single Json they can be ignored. But if they have also sub-json they should be treated as above. Basically from my point of view each array is like a separated Json file.
I know that flating the Json can be done as:
from pandas.io.json import json_normalize
json_normalize(sample_object)
But this won't work with arrays.
Any idea how to make this work?
EDIT:
This is how arrays should be handled:
source:
Output:
Which means first Json in array stays as is {0}, {1} etc... but the sub-jsons are flatted. There are no columns of attributes_0_value ! Basically convert it to array with a single Json. No nesting (unless there is another array).
Try using this:
import pandas as pd
import json
response = {u'total': 1245, u'limit': 2, u'results': [{u'customer': {u'lastName': u'rtyrtyrt', u'userAccountId': None, u'id': 637, u'firstName': u'rtyrtyrty', u'email': u'ddfgdfg#dfsdfgdfg.ggg'}, u'shippingAddress': {u'city': u'rtyrtyrtyrty', u'vatNumber': None, u'firstName': u'rtyrtyrty', u'companyName': None, u'country': {u'defaultCulture': {u'languageName': u'English', u'code': u'en-GB', u'id': 2, u'name': u'English'}, u'onlineStoreActive': True, u'currency': {u'symbol': u'\xa3', u'code': u'GBP', u'id': 2, u'currencyCulture': u'en-GB', u'numericCode': 826}, u'locale': None, u'isO2LetterCode': u'GB', u'vatPercentage': 20.0, u'continent': u'Europe ', u'isoNumericCode': u'826', u'invariantName': u'UNITED KINGDOM', u'id': 2, u'isO3LetterCode': u'GBR'}, u'stateProvince': None, u'lastName': u'rtyrtyrt', u'zipCode': u'5464556', u'email': u'ddfgdfg#dfsdfgdfg.ggg', u'addressLine2': None, u'addressLine1': u'tyrtyrty', u'phoneNumber': u'45644443456456546', u'addressName': None, u'id': 861}, u'orderDateUtc': u'0001-01-01 00:00', u'shoppingCardId': 0, u'paymentType': {u'code': u'SafeCharge', u'invariantName': u'Credit Card', u'id': 50}, u'orderNumber': u'0100000845', u'giftMessage': u'', u'storeId': 1, u'shippingService': {u'deletedOn': None, u'code': u'ROYALSTD', u'courier': None, u'updatedOn': u'2018-01-24 09:23', u'locale': None, u'createdOn': u'2018-01-24 09:23', u'storeId': 1, u'sortOrder': 1, u'invariantName': u'Royal Mail Standard', u'id': 1}, u'referenceOrderNumber': u'', u'totals': {u'shippingChargesNet': 3.95, u'orderLevelDiscount': 0.0, u'grandTotal': 8.95, u'vatPercentage': 20.0, u'shippingChargesDiscount': 0.0, u'shippingCharges': 3.95, u'units': 1, u'salesTaxPerc': 0.0, u'subTotal': 5.0, u'salesTax': 1.4916666666666667}, u'currency': {u'symbol': u'\xa3', u'code': u'GBP', u'id': 2, u'currencyCulture': u'en-GB', u'numericCode': 826}, u'status': {u'invariantName': u'Waiting PackingList', u'id': 4, u'name': None}, u'billingAddress': {u'city': u'rtyrtyrtyrty', u'vatNumber': None, u'firstName': u'rtyrtyrty', u'companyName': None, u'country': {u'defaultCulture': {u'languageName': u'English', u'code': u'en-GB', u'id': 2, u'name': u'English'}, u'onlineStoreActive': True, u'currency': {u'symbol': u'\xa3', u'code': u'GBP', u'id': 2, u'currencyCulture': u'en-GB', u'numericCode': 826}, u'locale': None, u'isO2LetterCode': u'GB', u'vatPercentage': 20.0, u'continent': u'Europe ', u'isoNumericCode': u'826', u'invariantName': u'UNITED KINGDOM', u'id': 2, u'isO3LetterCode': u'GBR'}, u'stateProvince': None, u'lastName': u'rtyrtyrt', u'zipCode': u'5464556', u'email': u'ddfgdfg#dfsdfgdfg.ggg', u'addressLine2': None, u'addressLine1': u'tyrtyrty', u'phoneNumber': u'456456456546', u'addressName': None, u'id': 861}, u'items': [{u'orderId': 844, u'discountEach': 0.0, u'cancellationId': 0, u'orderedQty': 1, u'giftMessage': u'', u'orderLevelDiscountEach': 0.0, u'historicalCategories': [], u'giftFrom': u'', u'netShippingChargesEach': 3.95, u'promotionItemIds': [], u'variantId': 11282, u'attributes': [{u'value': u'', u'key': u'ProductSeason'}], u'priceEach': 5.0, u'isGift': False, u'id': 939, u'giftTo': u''}], u'attributes': [{u'value': u'2', u'key': u'CustomerCultureId'}, {u'value': u'185.13.248.67', u'key': u'IpAddress'}, {u'value': u'UA', u'key': u'IpCountryCode'}, {u'value': u'OLS', u'key': u'OrderSource'}, {u'value': u'111790', u'key': u'SafeCharge_AuthCode'}, {u'value': u'UQBzAGQAaAB3ADgAMgB0AE4AagBHADUAegBpAHMAIwA7AC4ANgA3AFEAXwBMAGAAKwAqAHIAVgBGAEcAKQBFAD0ASQA8AC4ATgA0AD8ANQA+AFAAMwA=', u'key': u'SafeCharge_Token'}, {u'value': u'1512424599', u'key': u'SafeCharge_TransactionId'}, {u'value': u'1', u'key': u'StoreId'}], u'isGift': False, u'id': 844}, {u'customer': {u'lastName': u'dfgdfg', u'userAccountId': None, u'id': 638, u'firstName': u'dfgdfg', u'email': u'hfghfgh#dfdfg.fdg'}, u'shippingAddress': {u'city': u'fghfghhf', u'vatNumber': None, u'firstName': u'dfgdfg', u'companyName': None, u'country': {u'defaultCulture': {u'languageName': u'English', u'code': u'en-GB', u'id': 2, u'name': u'English'}, u'onlineStoreActive': True, u'currency': {u'symbol': u'\xa3', u'code': u'GBP', u'id': 2, u'currencyCulture': u'en-GB', u'numericCode': 826}, u'locale': None, u'isO2LetterCode': u'GB', u'vatPercentage': 20.0, u'continent': u'Europe ', u'isoNumericCode': u'826', u'invariantName': u'UNITED KINGDOM', u'id': 2, u'isO3LetterCode': u'GBR'}, u'stateProvince': None, u'lastName': u'dfgdfg', u'zipCode': u'4564566', u'email': u'hfghfgh#dfdfg.fdg', u'addressLine2': None, u'addressLine1': u'fghfghfgh', u'phoneNumber': u'567567567', u'addressName': None, u'id': 862}, u'orderDateUtc': u'0001-01-01 00:00', u'shoppingCardId': 0, u'paymentType': {u'code': u'SafeCharge', u'invariantName': u'Credit Card', u'id': 50}, u'orderNumber': u'0100000846', u'giftMessage': u'', u'storeId': 1, u'shippingService': {u'deletedOn': None, u'code': u'ROYALSTD', u'courier': None, u'updatedOn': u'2018-01-24 09:23', u'locale': None, u'createdOn': u'2018-01-24 09:23', u'storeId': 1, u'sortOrder': 1, u'invariantName': u'Royal Mail Standard', u'id': 1}, u'referenceOrderNumber': u'', u'totals': {u'shippingChargesNet': 3.95, u'orderLevelDiscount': 0.0, u'grandTotal': 8.95, u'vatPercentage': 20.0, u'shippingChargesDiscount': 0.0, u'shippingCharges': 3.95, u'units': 1, u'salesTaxPerc': 0.0, u'subTotal': 5.0, u'salesTax': 1.4916666666666667}, u'currency': {u'symbol': u'\xa3', u'code': u'GBP', u'id': 2, u'currencyCulture': u'en-GB', u'numericCode': 826}, u'status': {u'invariantName': u'Shipped', u'id': 6, u'name': None}, u'billingAddress': {u'city': u'fghfghhf', u'vatNumber': None, u'firstName': u'dfgdfg', u'companyName': None, u'country': {u'defaultCulture': {u'languageName': u'English', u'code': u'en-GB', u'id': 2, u'name': u'English'}, u'onlineStoreActive': True, u'currency': {u'symbol': u'\xa3', u'code': u'GBP', u'id': 2, u'currencyCulture': u'en-GB', u'numericCode': 826}, u'locale': None, u'isO2LetterCode': u'GB', u'vatPercentage': 20.0, u'continent': u'Europe ', u'isoNumericCode': u'826', u'invariantName': u'UNITED KINGDOM', u'id': 2, u'isO3LetterCode': u'GBR'}, u'stateProvince': None, u'lastName': u'dfgdfg', u'zipCode': u'4563334566', u'email': u'hfghfgh#dfdfg.fdg', u'addressLine2': None, u'addressLine1': u'fghfghfgh', u'phoneNumber': u'567567567', u'addressName': None, u'id': 862}, u'items': [{u'orderId': 845, u'discountEach': 0.0, u'cancellationId': 0, u'orderedQty': 1, u'giftMessage': u'', u'orderLevelDiscountEach': 0.0, u'historicalCategories': [], u'giftFrom': u'', u'netShippingChargesEach': 3.95, u'promotionItemIds': [], u'variantId': 11282, u'attributes': [{u'value': u'', u'key': u'ProductSeason'}], u'priceEach': 5.0, u'isGift': False, u'id': 940, u'giftTo': u''}], u'attributes': [{u'value': u'2', u'key': u'CustomerCultureId'}, {u'value': u'115.11.118.67', u'key': u'IpAddress'}, {u'value': u'UA', u'key': u'IpCountryCode'}, {u'value': u'OLS', u'key': u'OrderSource'}, {u'value': u'111335', u'key': u'SafeCharge_AuthCode'}, {u'value': u'UQA1AEYASgBVAEgAcgBvAE8AWAAlAFMAaABcAGAAMwA0AG4ATABiAHAAcQBoAEkAawB6AHMANQBXAEgAUQApACQATwBpAEQAUABAAGcAKwBcADQAMwA=', u'key': u'SafeCharge_Token'}, {u'value': u'1512424624', u'key': u'SafeCharge_TransactionId'}], u'isGift': False, u'id': 845}], u'offset': 0}
sample_object = pd.DataFrame(response)['results'].to_dict()
def flatten_json(y):
out = {}
def flatten(x, name=''):
if type(x) is dict:
for a in x:
flatten(x[a], name + a + '_')
elif type(x) is list:
out[name[:-1]] = x
else:
out[name[:-1]] = x
flatten(y)
return out
flat = {k: flatten_json(v) for k, v in sample_object.items()}
with open('flat.json', 'w') as jsonfile:
jsonfile.write(json.dumps(flat))
I personally use this procedure.
First store the JSON data as string (or, load from url or file)
use nested_to_record() method from pandas
import json
from pandas.io.json.normalize import nested_to_record
json_dic = json.loads(json_str)
flat = nested_to_record(json_dic, sep='_')
for key in flat:
print key, flat[key]
Output:

SugarCRM call records REST API

I am trying to get the call records from my SugarCRM account using the REST API and I am using Python.
There I want to obtain all the attendees but all I get is the user to whom the call is assigned.
u'assigned_user_id': u'xxxxxxxx',
The response I've received is,
{u'created_by_link': {u'id': u'1', u'full_name': u'adminx', u'_acl': {u'fields': {u'last_login': {u'write': u'no', u'create': u'no'}, u'pwd_last_changed': {u'write': u'no', u'create': u'no'}}, u'_hash': u'xxxx', u'delete': u'no'}}, u'dri_workflow_task_template_link': {u'_acl': {u'fields': [], u'_hash': u'xxxx'}, u'name': u'', u'id': u''},
u'customer_journey_points': 10,
u'dri_subworkflow_id': u'',
u'recurrence_id': u'',
u'created_by_name': u'adminx',
u'date_end': u'2018-05-02T09:45:00+00:00',
u'dri_subworkflow_template_id': u'',
u'parent_type': u'Accounts',
u'contact_id': u'xxxx',
u'_acl': {u'fields': {}},
u'duration_minutes': 30,
u'tag': [],
u'assigned_user_name': u'xxxx',
u'repeat_ordinal': u'',
u'repeat_count': None,
u'contact_name': u'xxxx',
u'repeat_interval': 1, u'id': u'xxxx', > - u'parent_name': u'ABC',
u'customer_journey_parent_activity_id': u'',
u'date_entered': u'2017-07-17T12:49:23+00:00',
u'outlook_id': u'',
u'team_name': [{u'name_2': u'', u'selected': False, u'primary': True, u'id': u'1', u'name': u'Global'}, {u'name_2': u'', u'selected': False, u'primary': False, u'id': u'West', u'name': u'West'}],
u'contacts': {u'_acl': {u'fields': [], u'_hash': u'xxxx'}, u'name': u'xxx', u'id': u'xxx'},
u'dri_workflow_task_template_id': u'',
u'customer_journey_score': None,
u'date_start': u'2018-05-02T09:15:00+00:00',
u'reminder_checked': u'',
u'dri_workflow_sort_order': u'1',
u'created_by': u'1',
u'parent_id': u'xxxx',
u'dri_subworkflow_template_link': {u'_acl': {u'fields': [], u'_hash': u'xxxx'}, u'name': u'', u'id': u''},
u'dri_subworkflow_name': u'',
u'dri_subworkflow_link': {u'_acl': {u'fields': [], u'_hash': u'xxxx'}, u'name': u'', u'id': u''},
u'modified_by_name': u'adminx',
u'repeat_selector': u'',
u'email_reminder_sent': False,
u'dri_workflow_template_id': u'',
u'status': u'Not Held',
u'direction': u'Outbound',
u'accept_status_users': u'',
u'repeat_dow': u'',
u'description': u'',
u'parent': {u'type': u'Accounts', u'_acl': {u'fields': [], u'_hash': u'xxxx'}, u'name': u'XYZ Funding Inc', u'id': u'xxxx'},
u'repeat_unit': u'',
u'deleted': False,
u'is_customer_journey_parent_activity': False,
u'customer_journey_parent_activity_type': u'',
u'locked_fields': [],
u'email_reminder_time': -1,
u'following': False,
u'assigned_user_link': {u'id': u'xxxx', u'full_name': u'xxxx', u'_acl': {u'fields': [], u'_hash': u'xxxx'}},
u'repeat_type': u'',
u'assigned_user_id': u'seed_sally_id',
u'team_count_link': {u'team_count': u'', u'id': u'1', u'_acl': {u'fields': [], u'_hash': u'xxxx'}},
u'dri_workflow_task_template_name': u'',
u'modified_user_link': {u'id': u'1', u'full_name': u'adminx', u'_acl': {u'fields': {u'last_login': {u'write': u'no', u'create': u'no'}, u'pwd_last_changed': {u'write': u'no', u'create': u'no'}}, u'_hash': u'xxx', u'delete': u'no'}},
u'email_reminder_checked': u'',
u'_module': u'Calls',
u'modified_user_id': u'1',
u'repeat_until': u'',
u'name': u'test',
u'date_modified': u'2017-07-17T12:49:23+00:00',
u'accept_status': u'',
u'reminder_time': -1,
u'customer_journey_progress': 0,
u'dri_workflow_template_name': u'',
u'my_favorite': False,
u'dri_subworkflow_template_name': u'',
u'dri_workflow_template_link': {u'_acl': {u'fields': [], u'_hash': u'xxx'}, u'name': u'', u'id': u''}, > - u'set_accept_links': u'',
u'repeat_days': u'',
u'is_customer_journey_activity': False,
u'repeat_parent_id': u'',
u'team_count': u'',
u'duration_hours': 0,
u'recurring_source': u''},
Strangely, the object which contains the list of "Guests" is not present in the standard GET request i.e.
https://{INSTANCE}/rest/v10/Calls/{RECORD_ID}
After doing some troubleshooting, and looking at the model in the web application itself, I found that the "Guests" field in the GUI ties back to a model property called "invitees".
Running a web request specifically referencing this field provides you with an array of records linked to the Call ID. So try running a GET request to this endpoint:
https://{INSTANCE}/rest/v10/Calls/{RECORD_ID}?fields=invitees
This should provide you with JSON akin to the below:
{
"id": "ec041f60-72b1-11e7-89f0-00163ef1f82f",
"date_modified": "2017-08-08T12:26:47+00:00",
"invitees": {
"records": [
{
"id": "cf378211-2b38-4fe5-949b-a53040717f04",
"date_modified": "2017-08-01T16:12:48+00:00",
"_acl": {
"fields": {}
},
"_module": "Users",
"_link": "users"
},
{
"id": "fe1740e6-3fa4-11e7-8fef-00163ef1f82f",
"date_modified": "2017-05-23T10:45:52+00:00",
"_acl": {
"fields": {}
},
"_module": "Contacts",
"_link": "contacts"
},
{
"id": "dcc526fc-72b1-11e7-a6dd-00163ef1f82f",
"date_modified": "2017-07-27T09:57:21+00:00",
"_acl": {
"fields": {}
},
"_module": "Leads",
"_link": "leads"
},
{
"id": "89f8a6d1-7df0-0e0b-3568-58a5bb6ecf34",
"date_modified": "2017-04-06T10:36:16+00:00",
"_acl": {
"fields": {}
},
"_module": "Leads",
"_link": "leads"
}
],
"next_offset": {
"contacts": -1,
"leads": -1,
"users": -1
}
},
"_acl": {
"fields": {}
},
"contact_name": "test",
"_module": "Calls"
}

Python :: nested JSON result in Spotify

I'm having a really hard time to get a track id in Spotify search endpoint.
It is deeply nested.
So, if I do this:
results = sp.search(q='artist:' + 'Nirvava + ' track:' + 'Milk it', type='track')
pprint.pprint(results)
I am able to get:
{u'tracks': {u'href': u'https://api.spotify.com/v1/search?query=artist%3ANirvana+track%3AMilk+it&type=track&offset=0&limit=10',
u'items': [{u'album': {u'album_type': u'album',
u'artists': [{u'external_urls': {u'spotify': u'https://open.spotify.com/artist/6olE6TJLqED3rqDCT0FyPh'},
u'href': u'https://api.spotify.com/v1/artists/6olE6TJLqED3rqDCT0FyPh',
u'id': u'6olE6TJLqED3rqDCT0FyPh',
u'name': u'Nirvana',
u'type': u'artist',
u'uri': u'spotify:artist:6olE6TJLqED3rqDCT0FyPh'}],
u'available_markets': [u'CA',
u'MX',
u'US'],
u'external_urls': {u'spotify': u'https://open.spotify.com/album/7wOOA7l306K8HfBKfPoafr'},
u'href': u'https://api.spotify.com/v1/albums/7wOOA7l306K8HfBKfPoafr',
u'id': u'7wOOA7l306K8HfBKfPoafr',
u'images': [{u'height': 640,
u'url': u'https://i.scdn.co/image/3dd2699f0fcf661c35d45745313b64e50f63f91f',
u'width': 640},
{u'height': 300,
u'url': u'https://i.scdn.co/image/a6c604a82d274e4728a8660603ef31ea35e9e1bd',
u'width': 300},
{u'height': 64,
u'url': u'https://i.scdn.co/image/f52728b0ecf5b6bfc998dfd0f6e5b6b5cdfe73f1',
u'width': 64}],
u'name': u'In Utero - 20th Anniversary Remaster',
u'type': u'album',
u'uri': u'spotify:album:7wOOA7l306K8HfBKfPoafr'},
u'artists': [{u'external_urls': {u'spotify': u'https://open.spotify.com/artist/6olE6TJLqED3rqDCT0FyPh'},
u'href': u'https://api.spotify.com/v1/artists/6olE6TJLqED3rqDCT0FyPh',
u'id': u'6olE6TJLqED3rqDCT0FyPh',
u'name': u'Nirvana',
u'type': u'artist',
u'uri': u'spotify:artist:6olE6TJLqED3rqDCT0FyPh'}],
u'available_markets': [u'CA', u'MX', u'US'],
u'disc_number': 1,
u'duration_ms': 234746,
u'explicit': False,
u'external_ids': {u'isrc': u'USGF19960708'},
u'external_urls': {u'spotify': u'https://open.spotify.com/track/4rtZtLpriBscg7zta3TZxp'},
u'href': u'https://api.spotify.com/v1/tracks/4rtZtLpriBscg7zta3TZxp',
u'id': u'4rtZtLpriBscg7zta3TZxp',
u'name': u'Milk It',
u'popularity': 43,
u'preview_url': None,
u'track_number': 8,
u'type': u'track',
-----> u'uri':u'spotify:track:4rtZtLpriBscg7zta3TZxp'},
QUESTION:
now, how do I fetch the last 'uri' (u'uri': u'spotify:track:4rtZtLpriBscg7zta3TZxp'}, under the name 'Milk It'?
>>> print results['tracks']['items'][0]['uri']
spotify:track:4rtZtLpriBscg7zta3TZxp

Paginate and collect posts and comments from Facebook (Python, Json) [duplicate]

I'm trying to pull posts and comments from Facebook for a project, but can't seem to pull everything. It seems that I get two links with previous and next
Here's my code:
import facebook
import requests
def some_action(post):
#print posts['data']
print(post['created_time'])
access_token = INSERT ACCESS TOKEN HERE
user = 'walkers'
graph = facebook.GraphAPI(access_token)
profile = graph.get_object(user)
posts = graph.get_connections(profile['id'], 'posts')
x = 0
while x < 900000:
#while True:
try:
posts = requests.get(posts['paging']['next']).json()
print (posts)
except KeyError:
break
x = x+1
My results are something like this:
{u'paging': {u'next': u' https://graph.facebook.com/v2.0/53198517648/posts?limit=25&__paging_token=enc_AdDr64IO8892JzsoPWiKkMDcF4lTDosOcP0H0ZB1mIpIW5EYRrCylZAji6ZBSCVBAVUYiS80oNtWtAL9GazXxRf0yva&access_token=INSERT ACCESS TOKEN HERE, u'previous': u' https://graph.facebook.com/v2.0/53198517648/posts?limit=25&__paging_token=enc_AdCqTjKBhfOsNBoKe3CJbnM2gU2RvLEYLgAQt1pHEcERVeK4qiw1dQAFHjt2sSInSZAIioZCqotwLMx8azzfZClIuCN&since=1430997206&access_token=INSERT ACCESS TOKEN HERE'}, u'data': [{u'picture': u'https://scontent.xx.fbcdn.net/hphotos-xfp1/v/t1.0-9/p130x130/11200605_10153202855322649_2472649283560371030_n.jpg?oh=50a0b3998e7bae8bb10c3a5f0854af46&oe=56556974', u'story': u'Walkers added 8 new photos to the album: 20 Years of Gary.', u'likes': {u'paging': {u'cursors': {u'after': u'MzgxNzk1MDQ4NjQ3MTI3', u'before': u'MTAxNTI0OTY1MDIwNDIyODI='}}, u'data': [{u'id': u'10152496502042282', u'name': u'Aaron Hanson'}, {u'id': u'10203040513950876', u'name': u'Gary GazRico Hinchliffe'}, {u'id': u'10152934096109345', u'name': u'Stuart Collister'}, {u'id': u'10152297022606059', u'name': u'Helen Preston'}, {u'id': u'326285380900188', u'name': u'Rhys Edwards'}, {u'id': u'10204744346589601', u'name': u'Aaron Benfield'}, {u'id': u'10200910780691953', u'name': u'Mike S Q Wilkins'}, {u'id': u'10204902354187051', u'name': u'Paul Owen Davies'}, {u'id': u'10152784755311784', u'name': u'Dafydd Ifan'}, {u'id': u'1517704468487365', u'name': u'Stephen Collier'}, {u'id': u'10202198826115234', u'name': u'John McKellar'}, {u'id': u'10151949129487143', u'name': u'Lucy Morrison'}, {u'id': u'1474199509524133', u'name': u'Christine Leek'}, {u'id': u'381795048647127', u'name': u'Sandra Taylor'}]}, u'from': {u'category': u'Product/Service', u'name':
These are the two links with the missing information:
u'https://graph.facebook.com/v2.0/53198517648/posts?limit=25&__paging_token=enc_AdDr64IO8892JzsoPWiKkMDcF4lTDosOcP0H0ZB1mIpIW5EYRrCylZAji6ZBSCVBAVUYiS80oNtWtAL9GazXxRf0yva&access_token=INSERT ACCESS TOKEN HERE',
u'previous': u'https://graph.facebook.com/v2.0/53198517648/posts?limit=25&__paging_token=enc_AdCqTjKBhfOsNBoKe3CJbnM2gU2RvLEYLgAQt1pHEcERVeK4qiw1dQAFHjt2sSInSZAIioZCqotwLMx8azzfZClIuCN&since=1430997206&access_token=INSERT ACCESS TOKEN HERE'
Obviously where I've put "INSERT ACCESS TOKEN HERE" I've removed the access token. Is there any way of getting all the data?

Google's Gmail API Python download attachments

I am trying to download e-mail attachments using Google's API-s but in this process, I bumped into some interesting errors:
Using Google's example (from here) for users.messages.attachments: get method , I've got a KeyError saying that there is no such keyword as data.
Using the method proposed in Download Attachments from gmail using Gmail API , TypeError: 'Resource' object is not callable is raised at the line:
att=gmail_service.users().messages().attachments().get(userId=user_id, messageId=msg_id,id=att_id).execute()
The relevant part of my code is:
import codecs
message = gmail_service.users().threads().get(id=thread['id'],userId='me',format='metadata').execute()['messages']
themessage = gmail_service.users().messages().get(userId='me', id=message[0]['id']).execute()
attachmentid = themessage['payload']['parts'][1]['body']['attachmentId'].encode('utf-8')
attachment = gmail_service().users().messages().attachments().get(userId='me',messageId=message[0]['id'], id=attachmentid).execute()
Thank you very much in advance and sorry for violating any kind of convention. I am a hobby programmer, my major is not even related to CS.
And the raw information of the e-mail:
{u'historyId': u'87616', u'id': u'14cc2903d8201ce5', u'snippet': u'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas dapibus leo auctor vulputate', u'sizeEstimate': 12503, u'threadId': u'14cc2903d8201ce5', u'labelIds': [u'INBOX', u'IMPORTANT', u'CATEGORY_PERSONAL', u'UNREAD'], u'payload': {u'mimeType': u'multipart/mixed', u'headers': [{u'name': u'Delivered-To', u'value': u'nagytomi1992#gmail.com'}, {u'name': u'Received', u'value': u'by 10.27.172.12 with SMTP id v12csp3301331wle; Thu, 16 Apr 2015 07:09:35 -0700 (PDT)'}, {u'name': u'X-Received', u'value': u'by 10.194.47.165 with SMTP id e5mr59439281wjn.128.1429193375163; Thu, 16 Apr 2015 07:09:35 -0700 (PDT)'}, {u'name': u'Return-Path', u'value': u'<nghuytungi#windowslive.com>'}, {u'name': u'Received', u'value': u'from DUB004-OMC2S3.hotmail.com (dub004-omc2s3.hotmail.com. [157.55.1.142]) by mx.google.com with ESMTPS id k8si15998291wia.75.2015.04.16.07.09.35 for <nagytomi1992#gmail.com> (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Apr 2015 07:09:35 -0700 (PDT)'}, {u'name': u'Received-SPF', u'value': u'pass (google.com: domain of nghuytungi#windowslive.com designates 157.55.1.142 as permitted sender) client-ip=157.55.1.142;'}, {u'name': u'Authentication-Results', u'value': u'mx.google.com; spf=pass (google.com: domain of nghuytungi#windowslive.com designates 157.55.1.142 as permitted sender) smtp.mail=nghuytungi#windowslive.com'}, {u'name': u'Received', u'value': u'from DUB122-W21 ([157.55.1.137]) by DUB004-OMC2S3.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.22751);\t Thu, 16 Apr 2015 07:09:34 -0700'}, {u'name': u'X-TMN', u'value': u'[u8z/PkebpkoUTRJcKA0Traso7CgFYEaU5ZPsEYJzyy0=]'}, {u'name': u'X-Originating-Email', u'value': u'[nghuytungi#windowslive.com]'}, {u'name': u'Message-ID', u'value': u'<DUB122-W210C6AC460DD3A13E54414D0E40#phx.gbl>'}, {u'name': u'Return-Path', u'value': u'nghuytungi#windowslive.com'}, {u'name': u'Content-Type', u'value': u'multipart/mixed; boundary="_7a3a4cda-38d8-405f-985d-255abada5722_"'}, {u'name': u'From', u'value': u'Tung Nguyen Huy <nghuytungi#windowslive.com>'}, {u'name': u'To', u'value': u'"nagytomi1992#gmail.com" <nagytomi1992#gmail.com>'}, {u'name': u'Subject', u'value': u'Chicago'}, {u'name': u'Date', u'value': u'Thu, 16 Apr 2015 16:09:34 +0200'}, {u'name': u'Importance', u'value': u'Normal'}, {u'name': u'MIME-Version', u'value': u'1.0'}, {u'name': u'X-OriginalArrivalTime', u'value': u'16 Apr 2015 14:09:34.0855 (UTC) FILETIME=[F77AD970:01D0784E]'}],
u'parts': [{u'mimeType': u'multipart/alternative', u'headers': [{u'name': u'Content-Type', u'value': u'multipart/alternative; boundary="_2c3faa5d-3517-45ad-9ae0-82a26eb7b6e5_"'}], u'parts': [{u'mimeType': u'text/plain', u'headers': [{u'name': u'Content-Type', u'value': u'text/plain; charset="iso-8859-1"'}, {u'name': u'Content-Transfer-Encoding', u'value': u'quoted-printable'}], u'body': {u'data': u'TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gTWFlY2VuYXMgZGF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ZlbCBmZXVnaWF0IGVmZmljaXR1ci4gRnVzY2UgYW50ZSB0ZWxsdXMsIGJpYmVuZHVtIGF0IHByZXRpdW0gYXVjdG9yLCBtYXR0aXMgZWdldCBpcHN1bS4gTnVuYyBzYWdpdHRpcyB0b3J0b3IgcXVpcyBhcmN1IHZpdmVycmEsIHZlbCBsb2JvcnRpcyBsYWN1cyBldWlzbW9kLiBRdWlzcXVlIGRpY3R1bSB0ZW1wb3IgYmliZW5kdW0uIFNlZCBtYXhpbXVzIGxpYmVybyBzaXQgYW1ldCBqdXN0byBmcmluZ2lsbGEgdHJpc3RpcXVlLiAJCSAJICAgCQkgIA==', u'size': 3451}, u'partId': u'0.0', u'filename': u''}, {u'mimeType': u'text/html', u'headers': [{u'name': u'Content-Type', u'value': u'text/html; charset="iso-8859-1"'}, {u'name': u'Content-Transfer-Encoding', u'value': u'quoted-printable'}], u'body': {u'data': u'PGh0bWw-DQo8aGVhZD4NCjxzdHlsZT48IS0tDQouaG1tZXNzYWdlIFANCnsNCm1hcmdpbjowcHg7DQpwYWRkaW5nOjBweA0KfQ0KYm9keS5obW1lc3NhZ2UNCnsNCmZvbnQtc2l6ZTogMTJwdDsNCmZvbnQtZmFtaWx5OkNhbGlicmkNCn0NCi0tPjwvc3R5bGU-PC9oZWFkPg0KPGJvZHkgY2xhc3M9J2htbWVzc2FnZSc-PGRpdiBkaXI9J2x0cic-PHAgc3R5bGU9ImNvbG9yOiByZ2IoMzQsIDM0LCAzNCk7IGZvbnQtZmFtaWx5OiBhcmlhbCwgc2Fucy1zZXJpZjsgZm9udC1zaXplOiAxMi44MDAwMDAxOTA3MzQ5cHg7IHRleHQtYWxpZ246IGp1c3RpZnk7IG1hcmdpbi1ib3R0b206IDE0cHg7IGJhY2tncm91bmQtY29sb3I6IHJnYigyNTUsIDI1NSwgMjU1KTsiPjxmb250IGNvbG9yPSIjMDAwMDAwIiBmYWNlPSJBcmlhbCwgSGVsdmV0aWNhLCBzYW5zIj48c3BhbiBzdH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}, u'partId': u'0.1', u'filename': u''}], u'body': {u'size': 0}, u'filename': u''},
{u'mimeType': u'text/plain', u'headers': [{u'name': u'Content-Type', u'value': u'text/plain'}, {u'name': u'Content-Transfer-Encoding', u'value': u'base64'}, {u'name': u'Content-Disposition', u'value': u'attachment; filename="villamosE.txt"'}], u'body': {u'attachmentId': u'ANGjdJ8D_1cYbyaSlXR4LOH0WEcY5G0wXTmiG4d85fkEfkiVGtaicJ_sEsJBSj8UsRfQv79C2Now8DKKvpuN4uhA1x3WBGATfxtFHd6m8YUOQkWPUZje37eLFeLAHjF1eiGo3dg3PPNRidhowbB6dXw4WW2Nqd9DioX3K_M9JmxTq4q_X_GUUHB3R5X_Y9yE-tvFdzeKMdWHLQG5-ah5sVaRDjS4gaD6U2ibMHV75yLfNj3P17xPfG9zU4igMYSS6QPI60Ry5aM7M1S_C30amy-HfJpA6fi-gEqqBtpGHg', u'size': 748}, u'partId': u'1', u'filename': u'villamosE.txt'}],
u'body': {u'size': 0}, u'filename': u''}}
The not callable error seems to imply the last line of your code should read gmail_service.users(), not gmail_service().users() as it currently does

Categories

Resources