question

Upvotes
23 0 0 2

Filter for organizations with Empty GicsCode category via Python API

Using the Python Refinitiv.data API I want to filter for organizations without a GICS code. How can I setup the filter query to exactly filter for "" (empty string?)

This is the code I am using:

import refinitiv.data as rd
rd.open_session()
         
response = search.Definition(
                view = search.Views.ORGANISATIONS,
                filter = f"GicsCode xeq ''",
                select = 'OAPermID,CommonName,GicsCode',
                top=10000 # maximum number of rows
            ).get_data()

The result is an Empty List.

The code works, because when filtering for a GicsCode such as 20106020 I retrieve 1573 organizations.

However, not all organizations have a GicsCode. For example "Fox E-Mobility AG", organization OAPermID "5071502736" does not have a GicsCode, value is empty. How can I setup a filter to select organizations that do not have a Gics Code?

I would like to have an answer like filter req '' or isEmpty? Thanks

python#technologyrefinitiv-data-platformpython 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.

Upvotes
79.8k 257 52 75

@r.fernandez

Thank you for reaching out to us.

Please try this one:

response = search.Definition(
                view = search.Views.ORGANISATIONS,
                filter = f"GicsCode eq null",
                select = 'OAPermID,CommonName,GicsCode',
                top=100 # maximum number of rows
            ).get_data()
response.data.df

1714368108297.png



1714368108297.png (33.2 KiB)
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.

Upvotes
23 0 0 2

Hi @Jirapongse
Thanks for responding so quickly. Do you know if there is any formal documentation on the filter query language used? I'm also searching for ways to escape the quote sign, I'm getting the error for searching

key = "US 'Other OTC' and Grey Market"

Invalid filter: unexpected <s> immediately after string <'US '> (hint: escape literal <'> as <''>)
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.

@r.fernandez

The document is on the API docs.

Please share the full code that you are using.

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.