Options

A error

RapidstudentRapidstudent Member Posts: 8 Newbie
edited June 2020 in Help
I have a python code which capture website and save content into csv file. It can successfully run in Execute Python Operator and to save a file in my computer. However finally, A error " no rm_main() method is defined" appear.

How can I add any formula to make it disappear? I need to convert the type of my data such as exampleset ? Actually, I don't know it clearly because I am just a beginner. I  don't know why I successfully save a file but a error appear finally........  please help , please simply teach me how to solve it.

Thank you
Tagged:

Answers

  • Options
    hbajpaihbajpai Member Posts: 102 Unicorn
    @Rapidstudent

    The python scripting operator uses rm_main() as a _init_ type of function. This is the main function which executes first and maps to other functions you have in your script. You have to include this always in your code as suggested by the scripting operator.

    # rm_main is a mandatory function, 
    # the number of arguments has to be the number of input ports (can be none),
    #     or the number of input ports plus one if "use macros" parameter is set
    # if you want to use macros, use this instead and check "use macros" parameter:
    #def rm_main(data,macros):
    def rm_main(data):
        print('Hello, world!')
        # output can be found in Log View
        print(type(data))
    
        #your code goes here
    
        #for example:
        data2 = pandas.DataFrame([3,5,77,8])
    
        # connect 2 output ports to see the results
        return data, data2

    Best,
    Harshit
  • Options
    btamasbtamas Employee, Member Posts: 11 RM Team Member
    Hi @Rapidstudent,

    have you defined the
    rm_main()
    method in your script? It seems like it is missing. Please check out the tutorial processes in the help of the Execute Python Operator, where you can see some examples on how to use the operator.

    If you would post the process xml (you can get it by clicking the ,,Copy the process to the clipboard'' icon in the top right corner) here, along with your Python code, we could provide more specific guidance, about what could be the problem and how to solve it.

    Best,
    Bence Tamás
Sign In or Register to comment.