Split node, data split

```[
    {
        "id": "bc97ba3b1120916d",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "6b91f71dcb05eef7",
        "type": "split",
        "z": "bc97ba3b1120916d",
        "name": "",
        "splt": "\\n",
        "spltType": "len",
        "arraySplt": "5",
        "arraySpltType": "len",
        "stream": true,
        "addname": "",
        "x": 330,
        "y": 700,
        "wires": [
            [
                "8ebdd414a78f64ea",
                "8005318185fbaf88"
            ]
        ]
    },
    {
        "id": "c435cfde1c588352",
        "type": "ui_text_input",
        "z": "bc97ba3b1120916d",
        "name": "",
        "label": "scan",
        "tooltip": "",
        "group": "2decf6b88dbcceaf",
        "order": 2,
        "width": 0,
        "height": 0,
        "passthru": true,
        "mode": "text",
        "delay": 300,
        "topic": "topic",
        "topicType": "msg",
        "x": 150,
        "y": 700,
        "wires": [
            [
                "6b91f71dcb05eef7"
            ]
        ]
    },
    {
        "id": "8ebdd414a78f64ea",
        "type": "ui_text",
        "z": "bc97ba3b1120916d",
        "group": "2decf6b88dbcceaf",
        "order": 3,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "fixed ",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 490,
        "y": 700,
        "wires": []
    },
    {
        "id": "8005318185fbaf88",
        "type": "ui_text",
        "z": "bc97ba3b1120916d",
        "group": "2decf6b88dbcceaf",
        "order": 4,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "variable",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 500,
        "y": 760,
        "wires": []
    },
    {
        "id": "2decf6b88dbcceaf",
        "type": "ui_group",
        "name": "description",
        "tab": "32c3866651e1e470",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "32c3866651e1e470",
        "type": "ui_tab",
        "name": "testing tab",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]```


hi all , how to use the split , i am trying to get a data input in scan form via usb scanner, the data should be splited into fixed and varaible text output node ,for example , if i input a characters of helloworld, after 4 characters it should be split into fixed (hello) and variable (world) text output node`Preformatted text`

Your post needs editing as your backticks need to be on their own line.

You need to enter a number into fixed length for string split. Then route the payloads using msg.parts.index. Use a debug node set to complete message object to see all message properties after the split.

e.g

[{"id":"c435cfde1c588352","type":"ui_text_input","z":"bc97ba3b1120916d","name":"","label":"scan","tooltip":"","group":"2decf6b88dbcceaf","order":2,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"topic","topicType":"msg","x":150,"y":700,"wires":[["6b91f71dcb05eef7"]]},{"id":"6b91f71dcb05eef7","type":"split","z":"bc97ba3b1120916d","name":"","splt":"5","spltType":"len","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":330,"y":700,"wires":[["7dc761f8023a402b","36b8f2117d8b4d9e"]]},{"id":"7dc761f8023a402b","type":"switch","z":"bc97ba3b1120916d","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":700,"wires":[["8ebdd414a78f64ea"],["8005318185fbaf88"]]},{"id":"36b8f2117d8b4d9e","type":"debug","z":"bc97ba3b1120916d","name":"debug 2479","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":410,"y":640,"wires":[]},{"id":"8ebdd414a78f64ea","type":"ui_text","z":"bc97ba3b1120916d","group":"2decf6b88dbcceaf","order":3,"width":0,"height":0,"name":"","label":"fixed ","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":"","color":"#000000","x":610,"y":700,"wires":[]},{"id":"8005318185fbaf88","type":"ui_text","z":"bc97ba3b1120916d","group":"2decf6b88dbcceaf","order":4,"width":0,"height":0,"name":"","label":"variable","format":"{{msg.payload}}","layout":"row-spread","x":620,"y":760,"wires":[]},{"id":"2decf6b88dbcceaf","type":"ui_group","name":"description","tab":"32c3866651e1e470","order":1,"disp":true,"width":"6","collapse":false},{"id":"32c3866651e1e470","type":"ui_tab","name":"testing tab","icon":"dashboard","disabled":false,"hidden":false}]
1 Like

I was about to get grumpy about providing no context! - until I scrolled down the code :melting_face:

Not allowed, deep breaths, I hear music soothes the soul.

3 Likes

thanks for the reply , data is getting splitted into 4 characters(fixed) & 4 (variables)haracters

for example , if a a word (helloworld) of 10 characters , in fixed i want only 4 characters and remainig in variable text output , is it possible ?

, edited, pasting the code format is correct ? @marcus-j-davies

Don't sweat it's fine! :smile:

Your providing commentary was inside the 3 ``` making it look like you didn't providing any context, but you did - you're off the hook :wink:

Should be...

```
Code
```
Your comments

This could also be done in a function node using Javascript or a change node using JSONata, but here is the low code way.

[{"id":"aca93cd0f4471603","type":"ui_text_input","z":"d1395164b4eec73e","name":"","label":"scan","tooltip":"","group":"abdf61b808295e6a","order":2,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"topic","topicType":"msg","x":571.9999732971191,"y":5701.000201225281,"wires":[["75b04f722a0b6862"]]},{"id":"75b04f722a0b6862","type":"split","z":"d1395164b4eec73e","name":"","splt":"4","spltType":"len","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":711.9999732971191,"y":5701.000201225281,"wires":[["3026e7cb4aa022c2","265b635ea5a23dee"]]},{"id":"3026e7cb4aa022c2","type":"debug","z":"d1395164b4eec73e","name":"debug 2479","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":831.9999732971191,"y":5641.000201225281,"wires":[]},{"id":"265b635ea5a23dee","type":"switch","z":"d1395164b4eec73e","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":true,"outputs":2,"x":931.9999732971191,"y":5661.000201225281,"wires":[["c8b19db71bc81b7d"],["0bcc382a0642d0d2"]]},{"id":"c8b19db71bc81b7d","type":"ui_text","z":"d1395164b4eec73e","group":"abdf61b808295e6a","order":3,"width":0,"height":0,"name":"","label":"fixed ","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":"","color":"#000000","x":1071.9999732971191,"y":5661.000201225281,"wires":[]},{"id":"0bcc382a0642d0d2","type":"join","z":"d1395164b4eec73e","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":791.9999732971191,"y":5761.000201225281,"wires":[["1d3db2329acb3cd3"]]},{"id":"1d3db2329acb3cd3","type":"ui_text","z":"d1395164b4eec73e","group":"abdf61b808295e6a","order":4,"width":0,"height":0,"name":"","label":"variable","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":"","color":"#000000","x":1041.9999732971191,"y":5761.000201225281,"wires":[]},{"id":"abdf61b808295e6a","type":"ui_group","name":"description","tab":"32c3866651e1e470","order":1,"disp":true,"width":"6","collapse":false},{"id":"32c3866651e1e470","type":"ui_tab","name":"testing tab","icon":"dashboard","disabled":false,"hidden":false}]

[edit] removed unnecessary branching and therefore msg cloning

@E1cid thanks , its working

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.