Rule: Enrich-convert-excel-to-pandas-dataframe-with-possible-chaining
loading x elements...

Name: Enrich-convert-excel-to-pandas-dataframe-with-possible-chaining

Version: 9

Discussion Thread

Creator: initial_tools

Hardcoded Priority (supersedes the rating): 4.1

This Rule has moderator approval.

React to a task_convert_file_type with a require_format_pickled_pandas_dataframe.

If the file targeted by the require_format_pickled_pandas_dataframe is of type Excel (file ending .xlsx), runs Enrich_Convert_Excel_to_Pandas_Dataframe on it.

Otherwise creates a require_format_excel and waits until it is solved. In this way, multiple file conversions can be chained together automatically if necessary.

Note: The three Rules Enrich-convert-csv-to-excel-with-possible-chaining, Enrich-convert-excel-to-pandas-dataframe-with-possible-chaining and Enrich-convert-pandas-dataframe-to-csv-with-possible-chaining were designed together and can automatically trigger each other in a circular fashion, so that any of the three datatypes can be converted into any of the other two.

(A note for new developers joining LOD: the ability to chain different conversions together automatically is a fairly advanced feature, which is why this Rule is probably larger than you would expect. In contrast, the actual Program used for the file conversion is not very good and can't handle special cases. You are invited to implement better conversion algorithms and can use this Rule as a template.)

ID: 373

Created: May 16, 2019, 1:31 p.m.

full definition:

The below is the JSON description of this object.

It is annotated with links to the documentation of each component.

You can hide fields with default values to make things clearer, and copy it to a clipboard to make creating similar Rules and Options easier.

Rule

{ "name" : "Enrich-convert-excel-to-pandas-dataframe-with-possible-chaining", "description" : "React to a task_convert_file_type with a require_format_pickled_pandas_dataframe.

If the file targeted by the require_format_pickled_pandas_dataframe is of type Excel (file ending .xlsx), runs Enrich_Convert_Excel_to_Pandas_Dataframe on it.

Otherwise creates a require_format_excel and waits until it is solved. In this way, multiple file conversions can be chained together automatically if necessary.

Note: The three Rules Enrich-convert-csv-to-excel-with-possible-chaining, Enrich-convert-excel-to-pandas-dataframe-with-possible-chaining and Enrich-convert-pandas-dataframe-to-csv-with-possible-chaining were designed together and can automatically trigger each other in a circular fashion, so that any of the three datatypes can be converted into any of the other two.

(A note for new developers joining LOD: the ability to chain different conversions together automatically is a fairly advanced feature, which is why this Rule is probably larger than you would expect. In contrast, the actual Program used for the file conversion is not very good and can't handle special cases. You are invited to implement better conversion algorithms and can use this Rule as a template.)"
, "dependencies" : [

Dependency

{ "symbol" : "task_convert_file_type" }
,

Dependency

{ "symbol" : "require_format_pickled_pandas_dataframe" }
], "threshold" : 2.0, "trigger" :

Trigger

{ "repeat" : [ "theTask", "theRequireTag", "theFileToConvert" ], "arguments" : [

Tag filter (for search)

{ "type" : "tag", "var" : "theTask", "targeted_by" : [

Tag filter (for search)

{ "type" : "tag", "var" : "theRequireTag", "symbol" : "require_format_pickled_pandas_dataframe", "requirement_is_provided" : false, "arguments" : { "1" :

File filter

{ "type" : "file", "var" : "theFileToConvert" }
} }
], "symbol" : "task_convert_file_type", "task_is_finished" : false }
,

File filter (for search)

{ "type" : "file", "var" : "theFileIsAnExcelFile", "role" : "optional", "equals" : "theFileToConvert", "name_matches" : ".*\\.xlsx" }
] }
, "actions" : [

Create an Option

{ "type" : "create_option", "var" : "enrich-convert-excel-to-pandas-dataframe-with-possible-chaining", "name" : "enrich-convert-excel-to-pandas-dataframe-with-possible-chaining", "description" : "This Option handles conversion of a file from type x to type y. If type x is not available, it creates a temporary intermediate request to create a file of type x first:
-If the file has the correct format, execute the program, then take the result of the program and put a !provide Tag on it
-Else create an option with lower confidence (100):
-Create an intermediary require_ Tag
-Create another high-confidence option waiting for the solution to the intermediary require_ Tag. It will run the program and put a tag on it.
-Create cleanup- option: When the original require_ Tag is solved or nullified, !nullify the intermediary require_ Tag and deactivate the Option
"
, "confidence" : 1000, "trigger" :

Trigger

{ "deactivate_if" : { "theTask" : ["is_nullified", "is_finished"] } }
, "actions" : [

Conditionally execute actions

{ "type" : "conditional", "if" :

Reference exists Condition

{ "type" : "reference_exists", "exists" : "theFileIsAnExcelFile" }
, "then" : [

Execute a Program

{ "type" : "execute_program", "var" : "programExecutionEvent", "program" : "Enrich_Convert_Excel_to_Pandas_Dataframe", "arguments" : { "input_file" :

Variable

{ "type" : "variable", "var" : "theFileToConvert" }
, "the_require_tag" :

Variable

{ "type" : "variable", "var" : "theRequireTag" }
} }
], "else" : [

Create an Option

{ "type" : "create_option", "var" : "enable-convert-excel-to-pandas-dataframe-through-chaining", "name" : "enable-convert-excel-to-pandas-dataframe-through-chaining", "description" : "Create a require_format_excel Tag as an intermediary, then wait until the solution for it is provided and use it for further processing.", "confidence" : 100, "trigger" :

Trigger

{ "arguments" : [

Tag filter (for search)

{ "type" : "tag", "_comment" : "Don't create the tag if a duplicate of it already exists. That could lead to infinite recursion.", "var" : "intermediateTagAlreadyExists", "role" : "optional", "symbol" : "require_format_excel", "arguments" : { "0" : "theTask", "1" : "theFileToConvert" } }
] }
, "actions" : [

Conditionally execute actions

{ "type" : "conditional", "if" :

Reference exists Condition

{ "type" : "reference_exists", "exists" : "intermediateTagAlreadyExists" }
, "else" : [

Create a Tag

{ "type" : "create_tag", "var" : "theIntermediateRequireTag", "symbol" : "require_format_excel", "arguments" : [

Variable

{ "type" : "variable", "var" : "theTask" }
,

Variable

{ "type" : "variable", "var" : "theFileToConvert" }
], "mark_with" : ["signal"] }
,

Create an Option

{ "type" : "create_option", "var" : "enrich-convert-excel-to-pandas-dataframe-through-chaining", "name" : "enrich-convert-excel-to-pandas-dataframe-through-chaining", "description" : "Wait for a solution to theIntermediateRequireTag, then use that file and run Enrich_Convert_Excel_to_Pandas_Dataframe on it.", "confidence" : 1000, "trigger" :

Trigger

{ "arguments" : [

Tag filter (for search)

{ "type" : "tag", "targeted_by" : [

Tag filter (for search)

{ "type" : "tag", "symbol" : "!provide", "arguments" : { "1" :

File filter

{ "type" : "file", "var" : "theExcelFile" }
} }
], "equals" : "theIntermediateRequireTag", "requirement_is_provided" : true }
] }
, "actions" : [

Execute a Program

{ "type" : "execute_program", "_comment" : "Note that this program generates Options which will !provide for the require tag.", "var" : "programExecutionEvent", "program" : "Enrich_Convert_Excel_to_Pandas_Dataframe", "arguments" : { "input_file" :

Variable

{ "type" : "variable", "var" : "theExcelFile" }
, "the_require_tag" :

Variable

{ "type" : "variable", "var" : "theRequireTag" }
} }
] }
,

Create an Option

{ "type" : "create_option", "var" : "cleanup-enrich-convert-excel-to-pandas-dataframe-through-chaining", "name" : "cleanup-enrich-convert-excel-to-pandas-dataframe-through-chaining", "description" : "When the original theRequireTag is solved or nullified, !nullify theIntermediateRequireTag and deactivate enrich-convert-excel-to-pandas-dataframe-through-chaining", "confidence" : 9999, "trigger" :

Trigger

{ "arguments" : [

Tag filter (for search)

{ "type" : "tag", "_comment" : "This argument uses a double negative: While theRequireTag is neither nullified nor solved, the Option does not fire.", "role" : "excluded", "equals" : "theRequireTag", "requirement_is_provided" : false }
] }
, "actions" : [

Create a Tag

{ "type" : "create_tag", "symbol" : "!nullify", "arguments" : [

Variable

{ "type" : "variable", "var" : "theIntermediateRequireTag" }
] }
,

Create a Tag

{ "type" : "create_tag", "symbol" : "!deactivate_rule_or_option", "arguments" : [

Variable

{ "type" : "variable", "var" : "enrich-convert-excel-to-pandas-dataframe-through-chaining" }
] }
] }
] }
] }
] }
] }
], "existing_variables" : { "theTask" :

Variable

{ "type" : "tag" }
, "theRequireTag" :

Variable

{ "type" : "tag" }
, "theFileToConvert" :

Variable

{ "type" : "file" }
, "theFileIsAnExcelFile" :

Variable

{ "type" : "file" }
, "enrich-convert-excel-to-pandas-dataframe-with-possible-chaining" :

Variable

{ "type" : "option" }
} }

Rule

{ "name" : "Enrich-convert-excel-to-pandas-dataframe-with-possible-chaining", "description" : "React to a task_convert_file_type with a require_format_pickled_pandas_dataframe.

If the file targeted by the require_format_pickled_pandas_dataframe is of type Excel (file ending .xlsx), runs Enrich_Convert_Excel_to_Pandas_Dataframe on it.

Otherwise creates a require_format_excel and waits until it is solved. In this way, multiple file conversions can be chained together automatically if necessary.

Note: The three Rules Enrich-convert-csv-to-excel-with-possible-chaining, Enrich-convert-excel-to-pandas-dataframe-with-possible-chaining and Enrich-convert-pandas-dataframe-to-csv-with-possible-chaining were designed together and can automatically trigger each other in a circular fashion, so that any of the three datatypes can be converted into any of the other two.

(A note for new developers joining LOD: the ability to chain different conversions together automatically is a fairly advanced feature, which is why this Rule is probably larger than you would expect. In contrast, the actual Program used for the file conversion is not very good and can't handle special cases. You are invited to implement better conversion algorithms and can use this Rule as a template.)"
, "dependencies" : [

Dependency

{ "symbol" : "task_convert_file_type", "weight" : 1.0, "comment_filter" : null }
,

Dependency

{ "symbol" : "require_format_pickled_pandas_dataframe", "weight" : 1.0, "comment_filter" : null }
], "threshold" : 2.0, "trigger" :

Trigger

{ "repeat" : [ "theTask", "theRequireTag", "theFileToConvert" ], "arguments" : [

Tag filter (for search)

{ "type" : "tag", "var" : "theTask", "role" : "required", "search_type" : "last", "search_postfilter" : null, "targeted_by" : [

Tag filter (for search)

{ "type" : "tag", "var" : "theRequireTag", "role" : "required", "search_type" : "last", "search_postfilter" : null, "targeted_by" : [], "equals" : null, "created_by" : null, "created_earlier_than" : null, "created_in_same_event_as" : null, "created_later_than" : null, "is_reserved" : null, "symbol" : "require_format_pickled_pandas_dataframe", "comment" : null, "comment_contains" : null, "comment_matches" : null, "weight" : null, "min_weight" : null, "max_weight" : null, "nullified" : false, "requirement_is_provided" : false, "task_is_finished" : null, "arguments" : { "1" :

File filter

{ "type" : "file", "var" : "theFileToConvert", "role" : "required", "targeted_by" : [], "equals" : null, "created_by" : null, "created_earlier_than" : null, "created_in_same_event_as" : null, "created_later_than" : null, "is_reserved" : null, "name_matches" : null }
} }
], "equals" : null, "created_by" : null, "created_earlier_than" : null, "created_in_same_event_as" : null, "created_later_than" : null, "is_reserved" : null, "symbol" : "task_convert_file_type", "comment" : null, "comment_contains" : null, "comment_matches" : null, "weight" : null, "min_weight" : null, "max_weight" : null, "nullified" : false, "requirement_is_provided" : null, "task_is_finished" : false, "arguments" : {} }
,

File filter (for search)

{ "type" : "file", "var" : "theFileIsAnExcelFile", "role" : "optional", "search_type" : "last", "search_postfilter" : null, "targeted_by" : [], "equals" : "theFileToConvert", "created_by" : null, "created_earlier_than" : null, "created_in_same_event_as" : null, "created_later_than" : null, "is_reserved" : null, "name_matches" : ".*\\.xlsx" }
], "deactivate_if" : {} }
, "actions" : [

Create an Option

{ "type" : "create_option", "var" : "enrich-convert-excel-to-pandas-dataframe-with-possible-chaining", "name" : "enrich-convert-excel-to-pandas-dataframe-with-possible-chaining", "description" : "This Option handles conversion of a file from type x to type y. If type x is not available, it creates a temporary intermediate request to create a file of type x first:
-If the file has the correct format, execute the program, then take the result of the program and put a !provide Tag on it
-Else create an option with lower confidence (100):
-Create an intermediary require_ Tag
-Create another high-confidence option waiting for the solution to the intermediary require_ Tag. It will run the program and put a tag on it.
-Create cleanup- option: When the original require_ Tag is solved or nullified, !nullify the intermediary require_ Tag and deactivate the Option
"
, "confidence" : 1000, "trigger" :

Trigger

{ "repeat" : "never", "arguments" : [], "deactivate_if" : { "theTask" : ["is_nullified", "is_finished"] } }
, "display" : null, "actions" : [

Conditionally execute actions

{ "type" : "conditional", "if" :

Reference exists Condition

{ "type" : "reference_exists", "exists" : "theFileIsAnExcelFile" }
, "then" : [

Execute a Program

{ "type" : "execute_program", "var" : "programExecutionEvent", "program" : "Enrich_Convert_Excel_to_Pandas_Dataframe", "arguments" : { "input_file" :

Variable

{ "type" : "variable", "nullable" : false, "var" : "theFileToConvert" }
, "the_require_tag" :

Variable

{ "type" : "variable", "nullable" : false, "var" : "theRequireTag" }
}, "argument_lists" : {} }
], "else" : [

Create an Option

{ "type" : "create_option", "var" : "enable-convert-excel-to-pandas-dataframe-through-chaining", "name" : "enable-convert-excel-to-pandas-dataframe-through-chaining", "description" : "Create a require_format_excel Tag as an intermediary, then wait until the solution for it is provided and use it for further processing.", "confidence" : 100, "trigger" :

Trigger

{ "repeat" : "never", "arguments" : [

Tag filter (for search)

{ "type" : "tag", "_comment" : "Don't create the tag if a duplicate of it already exists. That could lead to infinite recursion.", "var" : "intermediateTagAlreadyExists", "role" : "optional", "search_type" : "last", "search_postfilter" : null, "targeted_by" : [], "equals" : null, "created_by" : null, "created_earlier_than" : null, "created_in_same_event_as" : null, "created_later_than" : null, "is_reserved" : null, "symbol" : "require_format_excel", "comment" : null, "comment_contains" : null, "comment_matches" : null, "weight" : null, "min_weight" : null, "max_weight" : null, "nullified" : false, "requirement_is_provided" : null, "task_is_finished" : null, "arguments" : { "0" : "theTask", "1" : "theFileToConvert" } }
], "deactivate_if" : {} }
, "display" : null, "actions" : [

Conditionally execute actions

{ "type" : "conditional", "if" :

Reference exists Condition

{ "type" : "reference_exists", "exists" : "intermediateTagAlreadyExists" }
, "then" : [], "else" : [

Create a Tag

{ "type" : "create_tag", "var" : "theIntermediateRequireTag", "symbol" : "require_format_excel", "comment" : null, "weight" : null, "arguments" : [

Variable

{ "type" : "variable", "nullable" : false, "var" : "theTask" }
,

Variable

{ "type" : "variable", "nullable" : false, "var" : "theFileToConvert" }
], "mark_with" : ["signal"] }
,

Create an Option

{ "type" : "create_option", "var" : "enrich-convert-excel-to-pandas-dataframe-through-chaining", "name" : "enrich-convert-excel-to-pandas-dataframe-through-chaining", "description" : "Wait for a solution to theIntermediateRequireTag, then use that file and run Enrich_Convert_Excel_to_Pandas_Dataframe on it.", "confidence" : 1000, "trigger" :

Trigger

{ "repeat" : "never", "arguments" : [

Tag filter (for search)

{ "type" : "tag", "var" : null, "role" : "required", "search_type" : "last", "search_postfilter" : null, "targeted_by" : [

Tag filter (for search)

{ "type" : "tag", "var" : null, "role" : "required", "search_type" : "last", "search_postfilter" : null, "targeted_by" : [], "equals" : null, "created_by" : null, "created_earlier_than" : null, "created_in_same_event_as" : null, "created_later_than" : null, "is_reserved" : null, "symbol" : "!provide", "comment" : null, "comment_contains" : null, "comment_matches" : null, "weight" : null, "min_weight" : null, "max_weight" : null, "nullified" : false, "requirement_is_provided" : null, "task_is_finished" : null, "arguments" : { "1" :

File filter

{ "type" : "file", "var" : "theExcelFile", "role" : "required", "targeted_by" : [], "equals" : null, "created_by" : null, "created_earlier_than" : null, "created_in_same_event_as" : null, "created_later_than" : null, "is_reserved" : null, "name_matches" : null }
} }
], "equals" : "theIntermediateRequireTag", "created_by" : null, "created_earlier_than" : null, "created_in_same_event_as" : null, "created_later_than" : null, "is_reserved" : null, "symbol" : null, "comment" : null, "comment_contains" : null, "comment_matches" : null, "weight" : null, "min_weight" : null, "max_weight" : null, "nullified" : false, "requirement_is_provided" : true, "task_is_finished" : null, "arguments" : {} }
], "deactivate_if" : {} }
, "display" : null, "actions" : [

Execute a Program

{ "type" : "execute_program", "_comment" : "Note that this program generates Options which will !provide for the require tag.", "var" : "programExecutionEvent", "program" : "Enrich_Convert_Excel_to_Pandas_Dataframe", "arguments" : { "input_file" :

Variable

{ "type" : "variable", "nullable" : false, "var" : "theExcelFile" }
, "the_require_tag" :

Variable

{ "type" : "variable", "nullable" : false, "var" : "theRequireTag" }
}, "argument_lists" : {} }
] }
,

Create an Option

{ "type" : "create_option", "var" : "cleanup-enrich-convert-excel-to-pandas-dataframe-through-chaining", "name" : "cleanup-enrich-convert-excel-to-pandas-dataframe-through-chaining", "description" : "When the original theRequireTag is solved or nullified, !nullify theIntermediateRequireTag and deactivate enrich-convert-excel-to-pandas-dataframe-through-chaining", "confidence" : 9999, "trigger" :

Trigger

{ "repeat" : "never", "arguments" : [

Tag filter (for search)

{ "type" : "tag", "_comment" : "This argument uses a double negative: While theRequireTag is neither nullified nor solved, the Option does not fire.", "var" : null, "role" : "excluded", "search_type" : "last", "search_postfilter" : null, "targeted_by" : [], "equals" : "theRequireTag", "created_by" : null, "created_earlier_than" : null, "created_in_same_event_as" : null, "created_later_than" : null, "is_reserved" : null, "symbol" : null, "comment" : null, "comment_contains" : null, "comment_matches" : null, "weight" : null, "min_weight" : null, "max_weight" : null, "nullified" : false, "requirement_is_provided" : false, "task_is_finished" : null, "arguments" : {} }
], "deactivate_if" : {} }
, "display" : null, "actions" : [

Create a Tag

{ "type" : "create_tag", "var" : null, "symbol" : "!nullify", "comment" : null, "weight" : null, "arguments" : [

Variable

{ "type" : "variable", "nullable" : false, "var" : "theIntermediateRequireTag" }
], "mark_with" : [] }
,

Create a Tag

{ "type" : "create_tag", "var" : null, "symbol" : "!deactivate_rule_or_option", "comment" : null, "weight" : null, "arguments" : [

Variable

{ "type" : "variable", "nullable" : false, "var" : "enrich-convert-excel-to-pandas-dataframe-through-chaining" }
], "mark_with" : [] }
] }
] }
] }
] }
] }
], "existing_variables" : { "theTask" :

Variable

{ "type" : "tag", "value" : null }
, "theRequireTag" :

Variable

{ "type" : "tag", "value" : null }
, "theFileToConvert" :

Variable

{ "type" : "file", "value" : null }
, "theFileIsAnExcelFile" :

Variable

{ "type" : "file", "value" : null }
, "enrich-convert-excel-to-pandas-dataframe-with-possible-chaining" :

Variable

{ "type" : "option", "value" : null }
} }

all versions of this Rule:

Version 9

Version 8 (deleted)

Version 7 (deleted)

Version 6 (deleted)

Version 5 (deleted)

Version 4 (deleted)

Version 3 (deleted)

Version 2 (deleted)

Version 1 (deleted)