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?


Best Answer

  • Jirapongse
    Jirapongse admin
    Answer ✓

    @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