Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.
"how to properly use file_exists with branch operator?"
Hi, can anyone tell me what the condition value needs to be if one wants to check if a file exists or not using the branch operator?
If tried many things going from the actual file path to True or Yes but all are happily ignored.
If tried many things going from the actual file path to True or Yes but all are happily ignored.
Tagged:
0
Best Answer
-
lionelderkrikor RapidMiner Certified Analyst, Member Posts: 1,195 UnicornHi @kayman,
A priori, you have to set the "absolute path" of your file (including the extension) in the condition value parameter of the Branch operator.
Take a look at this process :<?xml version="1.0" encoding="UTF-8"?><process version="9.1.000"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="process" compatibility="9.1.000" expanded="true" name="Process"> <parameter key="logverbosity" value="init"/> <parameter key="random_seed" value="2001"/> <parameter key="send_mail" value="never"/> <parameter key="notification_email" value=""/> <parameter key="process_duration_for_mail" value="30"/> <parameter key="encoding" value="SYSTEM"/> <process expanded="true"> <operator activated="true" class="operator_toolbox:create_exampleset" compatibility="1.7.000" expanded="true" height="68" name="Create ExampleSet" width="90" x="112" y="85"> <parameter key="generator_type" value="comma_separated_text"/> <parameter key="number_of_examples" value="100"/> <parameter key="use_stepsize" value="false"/> <list key="function_descriptions"/> <parameter key="add_id_attribute" value="false"/> <list key="numeric_series_configuration"/> <list key="date_series_configuration"/> <list key="date_series_configuration (interval)"/> <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/> <parameter key="input_csv_text" value="Id,Att1 1,1 2,2 3,3 4,4"/> <parameter key="column_separator" value=","/> <parameter key="parse_all_as_nominal" value="false"/> <parameter key="decimal_point_character" value="."/> <parameter key="trim_attribute_names" value="true"/> </operator> <operator activated="true" class="concurrency:loop_files" compatibility="9.1.000" expanded="true" height="82" name="Loop Files" width="90" x="246" y="85"> <parameter key="directory" value="C:\Users\Lionel\Documents\Formations_DataScience\Rapidminer\Ambassador_Role"/> <parameter key="filter_type" value="glob"/> <parameter key="filter_by_glob" value="*.docx"/> <parameter key="filter_by_regex" value="*docx"/> <parameter key="recursive" value="false"/> <parameter key="enable_macros" value="false"/> <parameter key="macro_for_file_name" value="file_name"/> <parameter key="macro_for_file_type" value="file_type"/> <parameter key="macro_for_folder_name" value="folder_name"/> <parameter key="reuse_results" value="true"/> <parameter key="enable_parallel_execution" value="true"/> <process expanded="true"> <operator activated="true" class="branch" compatibility="9.1.000" expanded="true" height="103" name="Branch" width="90" x="313" y="34"> <parameter key="condition_type" value="file_exists"/> <parameter key="condition_value" value="C:\Users\Lionel\Documents\Formations_DataScience\Rapidminer\Ambassador_Role\Process.docx"/> <parameter key="expression" value=""/> <parameter key="io_object" value="ANOVAMatrix"/> <parameter key="return_inner_output" value="true"/> <process expanded="true"> <operator activated="true" class="generate_attributes" compatibility="9.1.000" expanded="true" height="82" name="Generate Attributes" width="90" x="179" y="136"> <list key="function_descriptions"> <parameter key="Att2" value="2*Att1"/> </list> <parameter key="keep_all" value="true"/> </operator> <connect from_port="condition" to_port="input 1"/> <connect from_port="input 1" to_op="Generate Attributes" to_port="example set input"/> <connect from_op="Generate Attributes" from_port="example set output" to_port="input 2"/> <portSpacing port="source_condition" spacing="0"/> <portSpacing port="source_input 1" spacing="0"/> <portSpacing port="source_input 2" spacing="0"/> <portSpacing port="sink_input 1" spacing="0"/> <portSpacing port="sink_input 2" spacing="0"/> <portSpacing port="sink_input 3" spacing="0"/> </process> <process expanded="true"> <operator activated="true" class="generate_attributes" compatibility="9.1.000" expanded="true" height="82" name="Generate Attributes (2)" width="90" x="179" y="85"> <list key="function_descriptions"> <parameter key="Att2" value="0"/> </list> <parameter key="keep_all" value="true"/> </operator> <connect from_port="condition" to_port="input 1"/> <connect from_port="input 1" to_op="Generate Attributes (2)" to_port="example set input"/> <connect from_op="Generate Attributes (2)" from_port="example set output" to_port="input 2"/> <portSpacing port="source_condition" spacing="0"/> <portSpacing port="source_input 1" spacing="0"/> <portSpacing port="source_input 2" spacing="0"/> <portSpacing port="sink_input 1" spacing="0"/> <portSpacing port="sink_input 2" spacing="0"/> <portSpacing port="sink_input 3" spacing="0"/> </process> </operator> <connect from_port="file object" to_op="Branch" to_port="condition"/> <connect from_port="input 1" to_op="Branch" to_port="input 1"/> <connect from_op="Branch" from_port="input 2" to_port="output 1"/> <portSpacing port="source_file object" spacing="0"/> <portSpacing port="source_input 1" spacing="0"/> <portSpacing port="source_input 2" spacing="0"/> <portSpacing port="sink_output 1" spacing="0"/> <portSpacing port="sink_output 2" spacing="0"/> </process> </operator> <connect from_op="Create ExampleSet" from_port="output" to_op="Loop Files" to_port="input 1"/> <connect from_op="Loop Files" from_port="output 1" to_port="result 1"/> <portSpacing port="source_input 1" spacing="0"/> <portSpacing port="sink_result 1" spacing="0"/> <portSpacing port="sink_result 2" spacing="0"/> </process> </operator> </process>
I hope it helps,
Regards and happy holidays,
Lionel
5
Answers
Seems like it's not working indeed if I use the 'windows user path logic' (which would have been /Documents/Formations_DataScience in your example), while ok if I use the C:\ path logic. I prefer the first one since it makes it equal to my Linux server environment and then I could have kept it simple.
Anyway, happy holidays for you also !