question

Upvotes
Accepted
54 1 0 5

Workspace Screener Output in Python produces errors when no results are found

When using the Workspace API in Python (under Windows 10), the program produces errors when the Screener results in no data returned.


For example, the command


screener_output=Screener('U(IN(Equity(active,public,primary))), IN(TR.NAICSNationalIndustryCode,"325520"), \
IN(TR.GICSSectorCode,"30"), DOES_NOT_CONTAIN(TR.CommonName,"Henkel AG & Co KGaA")')


returns no results, which means that the following command


df=dl.get_data(screener_output, ['TR.CommonName','TR.CompanyCntCountryAddr'], parameters={'NULL':'Blank'})


returns the error


RDError: Error code -1 | No values to unpack


How can the get_data command in this case be made to work, when the output from a screener is empty?


#technology#productpython api
icon clock
10 |1500

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

1 Answer

· Write an Answer
Upvotes
Accepted
84.6k 287 53 77

@IoannisG

Thank you for reaching out to us.

It could be a bug in the library. I will contact the product team to investigate this issue.

For a workaround, you can try the fundamental_and_reference in the content layer instead. The example is on GitHub.

from refinitiv.data.discovery import Screener
screener_output=Screener('U(IN(Equity(active,public,primary))), IN(TR.NAICSNationalIndustryCode,"325520"), \
IN(TR.GICSSectorCode,"30"), DOES_NOT_CONTAIN(TR.CommonName,"Henkel AG & Co KGaA")')


response = fundamental_and_reference.Definition(
       universe=[screener_output.expression],
       fields=['TR.CommonName','TR.CompanyCntCountryAddr'],
       parameters={'NULL':'Blank'}      
   ).get_data()
response.data.df


icon clock
10 |1500

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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