I'm using rdp to get data of private firms. I modified the code many times, but I kept get error like this. Could someone help me to fix this? Many thanks!
Below is my code:
import pandas as pd import refinitiv.dataplatform as rdp import time import logging def get_info(session, url, firm): try: endpoint = rdp.Endpoint(session=session, url=url) response = endpoint.send_request( method=rdp.Endpoint.RequestMethod.GET, path_parameters={"permId": firm}, ) logging.info(f"{firm} is processing!") logging.info(f"Response is {response.status['http_status_code']}") if response.is_success: try: wanted_response=response.data.raw['data']['businessClassification']['trbc'] logging.info(f"{firm} is completed!") return pd.DataFrame([wanted_response],index=[f'{firm}']) except AttributeError as e: logging.error(f"error for {firm}: {e}!") else: logging.error(f"error for {firm}: {response.status['http_status_code']}!") except Exception as e: logging.error(f"An unexpected error occurred for {firm}: {e}") return None # Set configuration session = rdp.open_platform_session( "...", rdp.GrantPassword( username="...", password="....." ) ) url="https://api.refinitiv.com/user-framework/mobile/overview-service/v1/corp/business-classification/{permId}" rdp.configure.config["http.request-timeout"] = 60 # import firm list df_firm = pd.read_stata(...Data/Match/Match_data/final_company_sample.dta') firm_list = df_firm['Company_PermID'].tolist() filtered_list=[] for value in firm_list: if value != "": filtered_list.append(value) # get information of each firm chunk_size=500 df=pd.DataFrame() for i in range(0, len(filtered_list), chunk_size): chunk = filtered_list[i:i + chunk_size] for firm in chunk: returned_df=get_info(session, url, firm) if returned_df is not None: df=pd.concat([df,returned_df],ignore_index=True) logging.info(f"Completed processing chunk {i + 1} to {min(i + chunk_size, len(filtered_list))}") time.sleep(1) df.to_excel(".../Data/Industry_TRBC.xlsx",index=False)