Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Python combining Audit metrics data logs from each API call

When ever I make an API call I am getting below sample data. Due to API call limitations ican only return 5000 recors at a time. if I have 50000 records I have to make 10 calls with 5000 records in each call.
Now I want to combine all these records into a single dictionary and then export into a csv file.

Code I have tried and failed, since the below codes are updating records in one of the dictionaries if the value exist


pd1 = pd.DataFrame(data)
pd2 = pd.DataFrame(data_1)
print(pd1.append(pd2))

def Merge(dict1, dict2):
res = {**dict1, **dict2}
return res

# Sample 2
dict1 = {'a': 10, 'b': 8}
dict2 = {'d': 6, 'c': 4}
dict3 = Merge(dict1, dict2)
print(dict3)

Sample Data:

*{'@odata.context': 'http://wabi-us-north-central-f-primary-redirect.analysis.windows.net/v1.0/myorg/admin/$metadata#grou...', '@odata.count': 2754, 'value': [{'id': 'ABCDEF-EC21-ABCDFEG-A6F9-fsdafsadf', 'isReadOnly': False, 'isOnDedicatedCapacity': True, 'capacityId': 'sdfasdfasd-F3A6-gfda-dsafas-asdfasd', 'capacityMigrationStatus': 'Migrated', 'type': 'Workspace', 'state': 'Active', 'name': 'DSS Dev Workspace', 'datasets': [{'id': 'sdfas-3436-fasdfas-a377-dsfa', 'name': 'Net Revenue Reporting v2', 'addRowsAPIEnabled': False, 'configuredBy': 'asdf.fdsa@asdfgasdf.com', 'isRefreshable': True, 'isEffectiveIdentityRequired': False, 'isEffectiveIdentityRolesRequired': False, 'targetStorageMode': 'Abf', 'createdDate': '2019-09-18T20:05:21.887Z', 'contentProviderType': 'PbixInImportMode', 'upstreamDatasets': [], 'schemaMayNotBeUpToDate': False, 'users': []}, {'id': 'e102e519-8fa1-4e2f-95b4-d6e0fa85960a', 'name': 'Month Stats Review (1)', 'addRowsAPIEnabled': False, 'configuredBy': 'fasd.fasd@afdsasd.com', 'isRefreshable': True, 'isEffectiveIdentityRequired': False, 'isEffectiveIdentityRolesRequired': False, 'targetStorageMode': 'Abf', 'createdDate': '2020-02-28T21:27:09.147Z', 'contentProviderType': 'PbixInImportMode', 'upstreamDatasets': [], 'schemaMayNotBeUpToDate': False, 'users': []}]}]}*

2 REPLIES 2
Anonymous
Not applicable

Hi Guys

I eneded up going one level down (value property) where the data is stored in list format. I have appended all data to a list and exported to txt file. As shown below.

 

'value': [{'id': 'ABCDEF-EC21-ABCDFEG-A6F9-fsdafsadf', 'isReadOnly': False, 'isOnDedicatedCapacity': True, 'capacityId': 'sdfasdfasd-F3A6-gfda-dsafas-asdfasd', 'capacityMigrationStatus': 'Migrated', 'type': 'Workspace', 'state': 'Active', 'name': 'DSS Dev Workspace', 'datasets': [{'id': 'sdfas-3436-fasdfas-a377-dsfa', 'name': 'Net Revenue Reporting v2', 'addRowsAPIEnabled': False, 'configuredBy': 'asdf.fdsa@asdfgasdf.com', 'isRefreshable': True, 'isEffectiveIdentityRequired': False, 'isEffectiveIdentityRolesRequired': False, 'targetStorageMode': 'Abf', 'createdDate': '2019-09-18T20:05:21.887Z', 'contentProviderType': 'PbixInImportMode', 'upstreamDatasets': [], 'schemaMayNotBeUpToDate': False, 'users': []}, {'id': 'e102e519-8fa1-4e2f-95b4-d6e0fa85960a', 'name': 'Month Stats Review (1)', 'addRowsAPIEnabled': False, 'configuredBy': 'fasd.fasd@afdsasd.com', 'isRefreshable': True, 'isEffectiveIdentityRequired': False, 'isEffectiveIdentityRolesRequired': False, 'targetStorageMode': 'Abf', 'createdDate': '2020-02-28T21:27:09.147Z', 'contentProviderType': 'PbixInImportMode', 'upstreamDatasets': [], 'schemaMayNotBeUpToDate': False, 'users': []}]}]

 

 

v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

I found some blogs, I hope they can help you.

Use Python in Power Query Editor

How to use Python/R to analyze a joined table in Power BI?

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.