Hello,
 I was sent here after opening a ticket at the help desk.  
I am trying to download data through python for a certain number of industries for a few specific variables.  Here is the code that I'm using but it's not working.
import eikon as ek
import pandas as pd
# Set your Eikon API key
ek.set_app_key('4c19fc66a2524a0f990085ea12a37f58816bce51')
# List of industry codes (based on your previous request)
industry_codes = [
    '5510','1510', '4020', '2520', '1510', '5520', '1510', '1010', '4510', '1010', 
    '2010', '2530', '2010', '4010', '4020', '2030', '3020', '101020', '2030', '4520', 
    '101020', '2010', '4520', '2520', '3010', '6010', '2020', '2510', '151040', '3020', 
    '2530', '2030', '3020', '2530', '4020', '2550', '2520', '4030', '5020', '3520', 
    '5530', '4520', '2550', '2520', '4030', '5020', '2530', '1510'
]
# List of variables to retrieve for each industry
variables = [
    'TR.CompanyName', 'TR.TRESGEmissionsScore', 'TR.PolicyEmissions', 'TR.AnalyticCO2', 
    'TR.AnalyticTotalWaste', 'TR.ClimateChangeRisksOpp', 'TR.AnalyticHazardousWaste', 
    'TR.AnalyticWasteRecyclingRatio', 'TR.AnalyticCO2IndirectScope3', 'TR.EnvPartnerships', 
    'TR.TargetsEmissions', 'TR.EnvRestorationInitiatives'
]
# Initialize an empty DataFrame to store all the data
all_data = pd.DataFrame()
# Loop through all industry codes and retrieve the data
for industry_code in industry_codes:
    try:
        # Query data for the current industry code
        data = ek.get_data(f'I:{industry_code}', variables)
        
        # Add a column for the industry code for tracking
        data['IndustryCode'] = industry_code
        
        # Append the data to the all_data DataFrame
        all_data = pd.concat([all_data, data], ignore_index=True)
        
        # Print progress (optional)
        print(f"Data for industry {industry_code} retrieved successfully.")
    except Exception as e:
        print(f"Error retrieving data for industry {industry_code}: {e}")
# Save the data to a CSV file (optional)
all_data.to_csv('industry_data.csv', index=False)
# Display a snippet of the data
print(all_data.head())
I'm getting this error:
Error retrieving data for industry 5510: 'tuple' object does not support item assignment
2025-04-03 13:54:35,311 P[93699] [MainThread 8020811904] Backend error. 400 Bad Request2025-04-03 13:54:35,313 P[93699] [MainThread 8020811904] HTTP request failed: EikonError-Backend error. 400 Bad Request
Error retrieving data for industry 1510: Error code 400 | Backend error. 400 Bad Request
2025-04-03 13:54:54,510 P[93699] [MainThread 8020811904] UDF Core request failed. Gateway Time-out2025-04-03 13:54:54,512 P[93699] [MainThread 8020811904] HTTP request failed: EikonError-UDF Core request failed. Gateway Time-out
Error retrieving data for industry 4020: Error code 2504 | UDF Core request failed. Gateway Time-outError retrieving data for industry 2520: 'tuple' object does not support item assignmentError retrieving data for industry 1510: 'tuple' object does not support item assignment
2025-04-03 13:59:41,445 P[93699] [MainThread 8020811904] Backend error. 400 Bad Request2025-04-03 13:59:41,447 P[93699] [MainThread 8020811904] HTTP request failed: EikonError-Backend error. 400 Bad Request
Error retrieving data for industry 5520: Error code 400 | Backend error. 400 Bad Request
......
I'm not sure what I'm doing wrong.
This is what the help desk said:
Hello Nicholas,
I appreciate the additional details you shared.
We have reviewed the syntax/ formula you have shared and the error message together with our Product Specialist team and we have identified that this is a script error which need to be raised in Developer portal. Developer portal will have experts in API that can assist.
 
Thank you,
Nicholas