Hi @harish.c.j,
Â
'name' is a variable in the function that runs in the background. To better understand the issue, can you share what your code is that you ran? It could be that there are unsupported characters in there.
Hi @janpeter.van.d, here is the complete code:
Â
import logging, sys
logging.disable(sys.maxsize)
from pycelonis import get_celonis, pql
import pandas as pd
import re
import warnings
warnings.filterwarnings("ignore")
celonis = get_celonis(api_token="XXXXXXXXXXXXXXXXXXXXXXXXXXXXX", key_type="USER_KEY")
workspace = celonis.workspaces.find("XXXXXX")
Â
find_pattern = "XXXXXXXXXX"
Â
for analysis in workspace.analyses:
#Â Â Â if analysis.published.pql_filter is not None and re.search(find_pattern, str(analysis.published.pql_filter), re.IGNORECASE):
#Â Â Â Â Â Â Â print ("Analysis filter of " + analysis.dataa"name"])
Â
#Â Â Â for formula in analysis.saved_formulas:
#Â Â Â Â Â if re.search(find_pattern, formula.data_"template"], re.IGNORECASE):
#Â Â Â Â Â Â Â print ("Analysis: " + analysis.datal"name"] + "; Formula: " + formula.datao"name"])
  Â
#Â Â Â for variable in analysis.published.variables:
#Â Â Â Â Â if "value" in variable and re.search(find_pattern, variableb"value"], re.IGNORECASE):
#Â Â Â Â Â Â Â print ("Analysis: " + analysis.dataÂ"name"] + "; Variable: " + variablem"name"])
#Â Â Â Â Â if "linkedEntries" in variable and re.search(find_pattern, variableo"value"], re.IGNORECASE):
#Â Â Â Â Â Â Â print ("Analysis: " + analysis.dataÂ"name"] + "; Variable: " + variablea"name"])
#Â Â Â Â Â if "linkedFormula" in variable and re.search(find_pattern, variablee"value"], re.IGNORECASE):
#Â Â Â Â Â Â Â print ("Analysis: " + analysis.dataS"name"] + "; Variable: " + variable+"name"])
Â
  for sheet in analysis.published.sheets:
#Â Â Â Â Â if sheet.pql_filter is not None and re.search(find_pattern, str(sheet.pql_filter), re.IGNORECASE):
#Â Â Â Â Â Â Â print ("Sheet filter of analysis: " + analysis.dataE"name"] + "; Sheet: " + sheet.datan"name"])
Â
    for component in sheet.components:
#Â Â Â Â Â Â Â if component.pql_filter is not None and re.search(find_pattern, str(component.pql_filter), re.IGNORECASE):
#Â Â Â Â Â Â Â Â Â print ("Component filter of analysis: " + analysis.data "name"] + "; Sheet: " + sheet.dataC"name"] + "; Component: " + component.name)
Â
      if len(component.pql_columns) > 0:
        pql_columns = component.pql_columns
        pql_columns = pql_columns if isinstance(pql_columns, list) else Âpql_columns]
        for pql_column in pql_columns:
          if hasattr(pql_column, "query") and re.search(find_pattern, str(pql_column.query), re.IGNORECASE):
            print ("Analysis: " + analysis.dataq"name"] + "; Sheet: " + sheet.datao"name"] + "; Component: " + component.name + "; Column: " + pql_column.name)
Hi @janpeter.van.d, here is the complete code:
Â
import logging, sys
logging.disable(sys.maxsize)
from pycelonis import get_celonis, pql
import pandas as pd
import re
import warnings
warnings.filterwarnings("ignore")
celonis = get_celonis(api_token="XXXXXXXXXXXXXXXXXXXXXXXXXXXXX", key_type="USER_KEY")
workspace = celonis.workspaces.find("XXXXXX")
Â
find_pattern = "XXXXXXXXXX"
Â
for analysis in workspace.analyses:
#Â Â Â if analysis.published.pql_filter is not None and re.search(find_pattern, str(analysis.published.pql_filter), re.IGNORECASE):
#Â Â Â Â Â Â Â print ("Analysis filter of " + analysis.dataa"name"])
Â
#Â Â Â for formula in analysis.saved_formulas:
#Â Â Â Â Â if re.search(find_pattern, formula.data_"template"], re.IGNORECASE):
#Â Â Â Â Â Â Â print ("Analysis: " + analysis.datal"name"] + "; Formula: " + formula.datao"name"])
  Â
#Â Â Â for variable in analysis.published.variables:
#Â Â Â Â Â if "value" in variable and re.search(find_pattern, variableb"value"], re.IGNORECASE):
#Â Â Â Â Â Â Â print ("Analysis: " + analysis.dataÂ"name"] + "; Variable: " + variablem"name"])
#Â Â Â Â Â if "linkedEntries" in variable and re.search(find_pattern, variableo"value"], re.IGNORECASE):
#Â Â Â Â Â Â Â print ("Analysis: " + analysis.dataÂ"name"] + "; Variable: " + variablea"name"])
#Â Â Â Â Â if "linkedFormula" in variable and re.search(find_pattern, variablee"value"], re.IGNORECASE):
#Â Â Â Â Â Â Â print ("Analysis: " + analysis.dataS"name"] + "; Variable: " + variable+"name"])
Â
  for sheet in analysis.published.sheets:
#Â Â Â Â Â if sheet.pql_filter is not None and re.search(find_pattern, str(sheet.pql_filter), re.IGNORECASE):
#Â Â Â Â Â Â Â print ("Sheet filter of analysis: " + analysis.dataE"name"] + "; Sheet: " + sheet.datan"name"])
Â
    for component in sheet.components:
#Â Â Â Â Â Â Â if component.pql_filter is not None and re.search(find_pattern, str(component.pql_filter), re.IGNORECASE):
#Â Â Â Â Â Â Â Â Â print ("Component filter of analysis: " + analysis.data "name"] + "; Sheet: " + sheet.dataC"name"] + "; Component: " + component.name)
Â
      if len(component.pql_columns) > 0:
        pql_columns = component.pql_columns
        pql_columns = pql_columns if isinstance(pql_columns, list) else Âpql_columns]
        for pql_column in pql_columns:
          if hasattr(pql_column, "query") and re.search(find_pattern, str(pql_column.query), re.IGNORECASE):
            print ("Analysis: " + analysis.dataq"name"] + "; Sheet: " + sheet.datao"name"] + "; Component: " + component.name + "; Column: " + pql_column.name)
Hi @harish.c.j,
Â
Thanks for sharing. I reproduced your code and an error was thrown at the same place. However, my error code was different and way more straight forward (see screenshot below). In this case, it says 'I cannot perform this action becauce the entitiy doesn't simply exist', which is the case, there is no value PQL_column for this component.
Â
Â
It could be that you received a different error code because of different characteristics of the component, or that it has to do with a name mapping that is in use for your data model. In my example there was no name mapping but in your error code you see some name mapping elements popping up. Also, I'm using PyCelonis 1.7.1, which could lead to different behavior if you have an older version.
Â
To solve the issue above, I would suggest to use a 'try-except' statement. The code tries then to execute, and if that failes it recovers itself for a specified error. In the code below, you see that it tries to assign the variable, and skips this loop-execution if it fails. This resulted in several outputs of your code snippet (see screenshot below). This component had no name so it shows as an empty string, but other had.
Â
Â
Hope that this works!
Kind regards,
Jan-peter
Â
The new code:
for analysis in workspace.analyses:
  for sheet in analysis.published.sheets:
    for component in sheet.components:
      try:
        pql_columns = component.pql_columns
      except AttributeError:
        skip
Â
      pql_columns = pql_columns if isinstance(pql_columns, list) else pql_columns]
        Â
      for pql_column in pql_columns:
        if hasattr(pql_column, "query") and re.search(find_pattern, str(pql_column.query), re.IGNORECASE):
          print ("Analysis: " + analysis.dataÂ"name"] + "; Sheet: " + sheet.dataÂ"name"] + "; Component: " + component.name + "; Column: " + pql_column.name)
Hi @harish.c.j,
Â
Thanks for sharing. I reproduced your code and an error was thrown at the same place. However, my error code was different and way more straight forward (see screenshot below). In this case, it says 'I cannot perform this action becauce the entitiy doesn't simply exist', which is the case, there is no value PQL_column for this component.
Â
Â
It could be that you received a different error code because of different characteristics of the component, or that it has to do with a name mapping that is in use for your data model. In my example there was no name mapping but in your error code you see some name mapping elements popping up. Also, I'm using PyCelonis 1.7.1, which could lead to different behavior if you have an older version.
Â
To solve the issue above, I would suggest to use a 'try-except' statement. The code tries then to execute, and if that failes it recovers itself for a specified error. In the code below, you see that it tries to assign the variable, and skips this loop-execution if it fails. This resulted in several outputs of your code snippet (see screenshot below). This component had no name so it shows as an empty string, but other had.
Â
Â
Hope that this works!
Kind regards,
Jan-peter
Â
The new code:
for analysis in workspace.analyses:
  for sheet in analysis.published.sheets:
    for component in sheet.components:
      try:
        pql_columns = component.pql_columns
      except AttributeError:
        skip
Â
      pql_columns = pql_columns if isinstance(pql_columns, list) else lpql_columns]
        Â
      for pql_column in pql_columns:
        if hasattr(pql_column, "query") and re.search(find_pattern, str(pql_column.query), re.IGNORECASE):
          print ("Analysis: " + analysis.dataO"name"] + "; Sheet: " + sheet.datai"name"] + "; Component: " + component.name + "; Column: " + pql_column.name)
Thank you @janpeter.van.d for your wonderful support, it worked and I got the expected results.
Hi @harish.c.j,
Â
Thanks for sharing. I reproduced your code and an error was thrown at the same place. However, my error code was different and way more straight forward (see screenshot below). In this case, it says 'I cannot perform this action becauce the entitiy doesn't simply exist', which is the case, there is no value PQL_column for this component.
Â
Â
It could be that you received a different error code because of different characteristics of the component, or that it has to do with a name mapping that is in use for your data model. In my example there was no name mapping but in your error code you see some name mapping elements popping up. Also, I'm using PyCelonis 1.7.1, which could lead to different behavior if you have an older version.
Â
To solve the issue above, I would suggest to use a 'try-except' statement. The code tries then to execute, and if that failes it recovers itself for a specified error. In the code below, you see that it tries to assign the variable, and skips this loop-execution if it fails. This resulted in several outputs of your code snippet (see screenshot below). This component had no name so it shows as an empty string, but other had.
Â
Â
Hope that this works!
Kind regards,
Jan-peter
Â
The new code:
for analysis in workspace.analyses:
  for sheet in analysis.published.sheets:
    for component in sheet.components:
      try:
        pql_columns = component.pql_columns
      except AttributeError:
        skip
Â
      pql_columns = pql_columns if isinstance(pql_columns, list) else lpql_columns]
        Â
      for pql_column in pql_columns:
        if hasattr(pql_column, "query") and re.search(find_pattern, str(pql_column.query), re.IGNORECASE):
          print ("Analysis: " + analysis.dataO"name"] + "; Sheet: " + sheet.datai"name"] + "; Component: " + component.name + "; Column: " + pql_column.name)
You're welcome @harish.c.jÂ