Tayyab Posted May 29 Share Posted May 29 (edited) I'm trying to use the below to search a workbook for the conditions off of a list. The returned list is empty. for x in conditions_found: alerts = spy.search({ 'Type': 'CalculatedCondition', 'Name': f'/{x}$/' }, workbook=workbook_id, limit=None) all_conditions = all_conditions.append(alerts, ignore_index=True) The resulting shows this: Query successful Type Name Time Count Pages Result 0 CalculatedCondition /Time Average Step Change (B-C)$/ 00:00:00.23 0 1 Success If I remove the regex and just do f'{x}' it works correctly. The documentation says that this format should be the same as what's done in the search bar in workbench. /{Time Average Step Change (B-C)}$/ works correctly in workbench. My seeq version is 62.0.17 and seeq-spy 192.22 and running this locally on VS code instead of datalab Edited May 29 by Tayyab Link to comment Share on other sites More sharing options...
Seeq Team Chris Harp Posted May 29 Seeq Team Share Posted May 29 Hi Tayyab, I am able to use regex within a spy search. Here's two example scripts that use the Example dataset that you can test. Example using a for loop with a list. from seeq import spy import pandas as pd import re search_results = spy.search( { 'Name': '/^Area [A-H]_Temperature$/', 'Type': 'Signal', 'Datasource Name': 'Example Data' } ) signal_list = search_results['Name'].tolist() all_conditions = pd.DataFrame() for x in signal_list: # Search for conditions related to the current signal name alerts = spy.search({ 'Name': f'/^{x}$/' }, limit=None) # Concatenate the search results to the all_conditions DataFrame all_conditions = pd.concat([all_conditions, alerts], ignore_index=True) all_conditions Example using a dataframe for the search parameters instead of a list. from seeq import spy import pandas as pd import re x= 'Area [A-H]_Temperature' search_results = spy.search( { 'Name': f'/^{x}$/', 'Type': 'Signal', 'Datasource Name': 'Example Data' } ) signal_list = search_results['Name'].tolist() search_df = pd.DataFrame({ 'Name': signal_list }) all_conditions = spy.search(search_df) all_conditions Hope this helps. Chris Link to comment Share on other sites More sharing options...
Solution Tayyab Posted May 29 Author Solution Share Posted May 29 Found the issue. My x variable was bringing in special characters which were being treated as regex. re.escape() around x solved it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now