# %% import json import pandas as pd ########################################## # %% # Load the JSON file data_path = '../esAppMod/tca_entities.json' with open(data_path, 'r') as file: data = json.load(file) # Initialize an empty list to store the rows rows = [] # %% # Loop through all entities in the JSON for entity in data["data"].items(): entity_data = entity[1] entity_id = entity_data['entity_id'] entity_name = entity_data['entity_name'] entity_type_id = entity_data['entity_type_id'] entity_type_name = entity_data['entity_type_name'] # Add each mention and its entity_id to the rows list rows.append( { 'id': entity_id, 'name': entity_name, 'type_id': entity_type_id, 'type_name': entity_type_name }) # Create a DataFrame from the rows df = pd.DataFrame(rows) # %% df.to_csv('entity.csv', index=False) # %%