Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Eikon Data APIs /
avatar image
Question by Erik77 · Aug 26, 2020 at 11:06 AM · eikon apiek.get_dataheaderskeyerror

KeyError: headers

Hi there,

I am trying to pull revenue segment data of companies based on a list of RIC codes. And get the keyerror: "headers".

My code looks as follows:

#Making list of instrument codes

riclist_HIP = data_2.Instrument.to_list()

#Calling the data

data_3,err = ek.get_data(riclist_HIP, ['TR.BGS.GeoTotalRevenue.segmentName', 'TR.BGS.GeoTotalRevenue','TR.CompanyName'])

data_3

Error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-17-b29cf30df8f5> in <module>
      1 #Making TR API Call
----> 2 data_3,err = ek.get_data(riclist_HIP, ['TR.BGS.GeoTotalRevenue.segmentName', 'TR.BGS.GeoTotalRevenue','TR.CompanyName'])
      3 data_3

~/opt/anaconda3/lib/python3.7/site-packages/eikon/data_grid.py in get_data(instruments, fields, parameters, field_name, raw_output, debug)
    195         return result
    196 
--> 197     return get_data_frame(result, field_name)
    198 
    199 

~/opt/anaconda3/lib/python3.7/site-packages/eikon/data_grid.py in get_data_frame(data_dict, field_name)
    244         headers = [header.get('field', header.get('displayName')) for header in data_dict['headers'][0]]
    245     else:
--> 246         headers = [header['displayName'] for header in data_dict['headers'][0]]
    247     data = pd.np.array([[get_data_value(value) for value in row] for row in data_dict['data']])
    248     if len(data):

KeyError: 'headers'

Could you please assist?

I saw other people have posted around this error but was unclear on how to adapt the solutions proposed to my case.

Many thanks in advance

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

3 Replies

  • Sort: 
avatar image
Best Answer
Answer by Erik77 · Aug 27, 2020 at 08:20 AM

The issue was that the RIC list I was trying to call was too long for the Eikon API to handle.

I divided the list into chunks and used a for loop to iterate over the chunks of the list.


See example below:

#Making chunks of the list of RICs in order for the API call to process it

chunklist = chunk(riclist, 100)

chunklist

#Using a for loop to get the data based on the chunks of RIC list

content_df = []

for subs in chunklist:

RICs = ek.get_symbology(subs, from_symbol_type='ISIN', to_symbol_type= 'RIC')

content_df.append(RICs)

content_df = pd.concat(content_df)

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Answer by chavalit.jintamalit · Aug 26, 2020 at 12:36 PM

Hi @Erik77

Please provide what API version you are using? (you can print out ek.__version__)

Please provide sample riclist_HiP (what RICs you used?)

Comment

People who like this

0 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
Erik77 · Aug 26, 2020 at 12:51 PM 0
Share

Hi @chavalit.jintamalit.

I am using version 1.1.2

Here is the sample of the RICs list.

['MAERSKb.CO','3319.HK','AAAA.L','2018.HK','AAK.ST','AALB.AS',
'CFEB.BR','AAON.OQ','AIR.N','ARLG.DE','AAN.N','ABP.AX','ABBN.S','ABT.N','ABBV.N','BITI.PA','2670.T','ABCA.L','ABG.MC','ABEO.OQ','ANF.N','ASL.L','nan','ABMD.OQ','ABM.N','ABNd.AS','AEV.PS',
'AP.PS','AXAS.OQ','ABGJ.J','ADCB.AD','ACIA.OQ','ACTG.OQ','ACADE.ST','ACHC.OQ','ACAD.OQ','AKR.N','ACC.NS','AXDX.OQ','XLRN.OQ',
'ACCG.AS','AX1.AX','ACN.N','4813.T','ACSO.L','ANA.MC','ACCO.N',
'ACCP.PA','2345.TW','ARAY.OQ','ACEh.V','ACES.JK','ACE.MI','2353.TW','ACX.MC','AKAOQ.PK','ACIW.OQ','ACKB.BR','ACRS.OQ','ACNB.OQ','8572.T','ACOR.OQ']


avatar image
REFINITIV
Answer by Alex Putkov. · Aug 26, 2020 at 03:52 PM

@Erik77

Thank you for providing the details. I'm afraid I do not reproduce the issue you describe.On my end the get_data call using the exact set of RICs and fields that you used returns the data as expected. Are you able to reproduce the issue consistently on your end? Is there any pattern to the problem you may have noticed?

Comment
Erik77

People who like this

1 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
Erik77 · Aug 27, 2020 at 08:17 AM 0
Share

Hi @Alex Putkov. Thanks for looking into it on your end. I found the solution.

The issue was that the RIC list I was trying to call was too long for the API to handle. I divided the list into chunks and used a for loop to iterate over the chunks of the list.

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
12 People are following this question.

Related Questions

getting KeyError: 'headers' from data request

Getting KeyError: "headers" from data request

Python Eikon Set app id

Eikon API Error

is there any equivalent of Rsearch in Python API?

  • Feedback
  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Careers
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Calais
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRIT
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • World-Check Data File
  • Explore
  • Tags
  • Questions
  • Badges