String Splitter:
The String Splitter node is designed to divide a given string into a specified number of parts, making it a versatile tool for text manipulation tasks. This node is particularly useful when you need to break down large blocks of text into smaller, more manageable segments. By leveraging the textwrap module, the node ensures that each part is approximately equal in length, providing a balanced distribution of text across the specified number of parts. This functionality is beneficial for tasks such as preparing text for display in limited space environments or for processing text in parallel operations. The node's ability to handle multiline strings and its flexibility in adjusting the number of parts make it an essential component for text processing workflows.
String Splitter Input Parameters:
input_string
The input_string parameter is the text that you want to split into parts. It accepts multiline strings, allowing you to work with complex text structures. This parameter is mandatory, meaning you must provide a string for the node to function. The content of this string directly influences the output, as it determines the text that will be divided into parts.
number_of_parts
The number_of_parts parameter specifies how many parts you want the input string to be divided into. It is an integer value with a default of 2, and it must be at least 1. This parameter controls the granularity of the split operation; a higher number results in more, smaller parts, while a lower number results in fewer, larger parts. Adjusting this parameter allows you to tailor the output to your specific needs, whether you require a detailed breakdown or a broader division of the text.
String Splitter Output Parameters:
Split Strings
The Split Strings output parameter provides the resulting list of strings after the input string has been divided according to the specified number of parts. Each element in this list represents a segment of the original text, with the node ensuring that the parts are as evenly distributed as possible. This output is crucial for further processing or analysis, as it allows you to handle each part individually, facilitating tasks such as parallel processing or targeted text manipulation.
String Splitter Usage Tips:
- To achieve the most balanced split, ensure that the
number_of_partsparameter is set to a value that divides the length of theinput_stringevenly. This will help maintain uniformity across the resulting parts. - If you need to ensure that each part contains a complete sentence or logical unit, consider preprocessing the
input_stringto insert delimiters at appropriate points before using the String Splitter node.
String Splitter Common Errors and Solutions:
Input string is empty
- Explanation: This error occurs when the
input_stringparameter is provided with an empty string. - Solution: Ensure that the
input_stringcontains text before passing it to the node. Check your input source to confirm that it is supplying the expected data.
Number of parts is less than 1
- Explanation: The
number_of_partsparameter must be at least 1, as a value less than this is invalid for splitting operations. - Solution: Adjust the
number_of_partsparameter to be 1 or greater. Verify that the input value is correctly set in your configuration or script.
