Carriage Return Text Search in Python STK

Options
mikcapelli
mikcapelli Member, Employee Posts: 5
First Anniversary First Comment Ansys Employee
edited November 2023 in Materials

Hi,

A particular Short Text attribute in a table has been filled with texts ending with carriage returns, but not on all records. In an effort to tidy up the data, the admin is developing a script whose intent is to search for records where the attribute value contains a carriage return.

Is it possible in the STK to use the "search_for_records_where" function calling a text search criteria with an ASCII code for carriage returns or special characters ? Basically, something like this :

base_contains_iron = base_attribute.search_criterion(contains='Fe (Iron) \r\n')
iron_records = material_universe.search_for_records_where([base_contains_iron])

Thanks in advance !

Mickaël

Best Answer

  • Toshihiko
    Toshihiko Member, Employee Posts: 1
    First Answer First Comment
    Answer ✓
    Options

    Hi Mickael-san
    I checked in my environment (local environment of Windows Server 2019).
    Carriage returns could not be detected by "search_criterion" and "search_for_records_where",
    so it can be detected by whether special characters are included in record.attributes['attribute'].value.

    A similar error, "Search.CriteriaSearch failed with code 500", occurred when searching for using only space or CR.

Answers

  • mikcapelli
    mikcapelli Member, Employee Posts: 5
    First Anniversary First Comment Ansys Employee
    Options

    !----UPDATE----!
    After a test done on Granta MI 2023 R1 with Python STK 3.1, I am getting the following error :

    error message transcripted below :
    Search.CriteriaSearch failed with code 500 and message: The server was unable to process the request due to an internal error.
    For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior)
    on the server in order to send the exception information back to the client,
    or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.

  • mikcapelli
    mikcapelli Member, Employee Posts: 5
    First Anniversary First Comment Ansys Employee
    Options

    Final update :

    Carriage returns could not be detected by "search_criterion" and "search_for_records_where",
    so it can be detected by whether special characters are included in record.attributes['attribute'].value.

    Thank you Toshihiko-san for your input.

This discussion has been closed.