1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

add examples for CSV node

This commit is contained in:
Hiroyasu Nishiyama 2020-11-03 14:34:34 +09:00
parent 15a600c763
commit 725c962236
10 changed files with 1142 additions and 0 deletions

View File

@ -0,0 +1,99 @@
[
{
"id": "330f4888.cccb28",
"type": "inject",
"z": "4b63452d.672afc",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 260,
"y": 180,
"wires": [
[
"ed11f8d6.5e3c88"
]
]
},
{
"id": "a0288b44.71d488",
"type": "csv",
"z": "4b63452d.672afc",
"name": "",
"sep": ",",
"hdrin": "",
"hdrout": "none",
"multi": "one",
"ret": "\\n",
"temp": "",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 600,
"y": 180,
"wires": [
[
"369cbe42.4af9f2"
]
]
},
{
"id": "ed11f8d6.5e3c88",
"type": "template",
"z": "4b63452d.672afc",
"name": "CSV data",
"field": "payload",
"fieldType": "msg",
"format": "text",
"syntax": "mustache",
"template": "Apple,100,Canada\nOrange,120,USA\nBanana,80,Philippines",
"output": "str",
"x": 430,
"y": 180,
"wires": [
[
"a0288b44.71d488"
]
]
},
{
"id": "369cbe42.4af9f2",
"type": "debug",
"z": "4b63452d.672afc",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 780,
"y": 180,
"wires": []
},
{
"id": "783cfaa6.52fbe4",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Partse CSV with default column name as messages",
"info": "CSV node can parse input CSV data.\nParsed CSV record can be send as a message sequence.\nEach message payload point to an object with `col`*N* as a key and CSV value as a value.\n",
"x": 330,
"y": 120,
"wires": []
}
]

View File

@ -0,0 +1,99 @@
[
{
"id": "98c9d44d.4457b8",
"type": "inject",
"z": "4b63452d.672afc",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 260,
"y": 360,
"wires": [
[
"65476517.3d760c"
]
]
},
{
"id": "76df98f7.0dcd08",
"type": "csv",
"z": "4b63452d.672afc",
"name": "",
"sep": ",",
"hdrin": "",
"hdrout": "none",
"multi": "mult",
"ret": "\\n",
"temp": "",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 600,
"y": 360,
"wires": [
[
"557979e0.e6b588"
]
]
},
{
"id": "65476517.3d760c",
"type": "template",
"z": "4b63452d.672afc",
"name": "CSV data",
"field": "payload",
"fieldType": "msg",
"format": "text",
"syntax": "mustache",
"template": "Apple,100,Canada\nOrange,120,USA\nBanana,80,Philippines",
"output": "str",
"x": 430,
"y": 360,
"wires": [
[
"76df98f7.0dcd08"
]
]
},
{
"id": "557979e0.e6b588",
"type": "debug",
"z": "4b63452d.672afc",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 780,
"y": 360,
"wires": []
},
{
"id": "187f4ab3.4c9ab5",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Partse CSV with default column name as array",
"info": "CSV node can send single message with array of parsed CSV records.\nEach element of the array consists of objects with key-value pair.",
"x": 320,
"y": 300,
"wires": []
}
]

View File

@ -0,0 +1,99 @@
[
{
"id": "1216e95b.1b1e87",
"type": "inject",
"z": "4b63452d.672afc",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 260,
"y": 560,
"wires": [
[
"e41ffbbc.de2ed8"
]
]
},
{
"id": "286828bc.9233c8",
"type": "csv",
"z": "4b63452d.672afc",
"name": "",
"sep": ",",
"hdrin": "",
"hdrout": "none",
"multi": "one",
"ret": "\\n",
"temp": "kind,price,origin",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 600,
"y": 560,
"wires": [
[
"9d8218c.5550ee8"
]
]
},
{
"id": "e41ffbbc.de2ed8",
"type": "template",
"z": "4b63452d.672afc",
"name": "CSV data",
"field": "payload",
"fieldType": "msg",
"format": "text",
"syntax": "mustache",
"template": "Apple,100,Canada\nOrange,120,USA\nBanana,80,Philippines",
"output": "str",
"x": 430,
"y": 560,
"wires": [
[
"286828bc.9233c8"
]
]
},
{
"id": "9d8218c.5550ee8",
"type": "debug",
"z": "4b63452d.672afc",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 780,
"y": 560,
"wires": []
},
{
"id": "aaa1ee8f.21e2c",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Partse CSV with specified column name as messages",
"info": "CSV node can specify column name of parsed objects in its settings panel.",
"x": 340,
"y": 500,
"wires": []
}
]

View File

@ -0,0 +1,99 @@
[
{
"id": "24093558.0315aa",
"type": "inject",
"z": "4b63452d.672afc",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 260,
"y": 740,
"wires": [
[
"80abaee1.5fa7f"
]
]
},
{
"id": "d4d2ca3f.1d9488",
"type": "csv",
"z": "4b63452d.672afc",
"name": "",
"sep": ",",
"hdrin": true,
"hdrout": "none",
"multi": "one",
"ret": "\\n",
"temp": "",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 600,
"y": 740,
"wires": [
[
"b52791c3.08967"
]
]
},
{
"id": "80abaee1.5fa7f",
"type": "template",
"z": "4b63452d.672afc",
"name": "CSV data",
"field": "payload",
"fieldType": "msg",
"format": "text",
"syntax": "mustache",
"template": "kind,price,origin\nApple,100,Canada\nOrange,120,USA\nBanana,80,Philippines",
"output": "str",
"x": 430,
"y": 740,
"wires": [
[
"d4d2ca3f.1d9488"
]
]
},
{
"id": "b52791c3.08967",
"type": "debug",
"z": "4b63452d.672afc",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 780,
"y": 740,
"wires": []
},
{
"id": "85091361.85644",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Partse CSV with column name in first row as messages",
"info": "CSV node can use first row of input CSV text as a column name of each record object.\n",
"x": 340,
"y": 680,
"wires": []
}
]

View File

@ -0,0 +1,99 @@
[
{
"id": "9e93169c.b763a8",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Convert JavaScript object to CSV",
"info": "CSV node can convert a JavaScript object to CSV text.\nEach object contains key-value pair of specified properties.\n",
"x": 270,
"y": 860,
"wires": []
},
{
"id": "8ca41fee.3303d",
"type": "inject",
"z": "4b63452d.672afc",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 260,
"y": 920,
"wires": [
[
"c466905b.e8c61"
]
]
},
{
"id": "65146d20.d78204",
"type": "csv",
"z": "4b63452d.672afc",
"name": "",
"sep": ",",
"hdrin": false,
"hdrout": "none",
"multi": "one",
"ret": "\\n",
"temp": "kind,price",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 600,
"y": 920,
"wires": [
[
"92e99e67.a37d8"
]
]
},
{
"id": "c466905b.e8c61",
"type": "template",
"z": "4b63452d.672afc",
"name": "JS object",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "plain",
"template": "{\n \"kind\": \"Apple\",\n \"price\": 100,\n \"origin\": \"Canada\"\n}",
"output": "json",
"x": 430,
"y": 920,
"wires": [
[
"65146d20.d78204"
]
]
},
{
"id": "92e99e67.a37d8",
"type": "debug",
"z": "4b63452d.672afc",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 780,
"y": 920,
"wires": []
}
]

View File

@ -0,0 +1,99 @@
[
{
"id": "e89019c5.70ae78",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Convert array of JavaScript objects to CSV",
"info": "CSV node can convert an array of JavaScript objects to multi-line CSV text.",
"x": 300,
"y": 1020,
"wires": []
},
{
"id": "bd0d82ed.7b28",
"type": "inject",
"z": "4b63452d.672afc",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 260,
"y": 1080,
"wires": [
[
"1d857b8d.3a4014"
]
]
},
{
"id": "66a37667.16ebd8",
"type": "csv",
"z": "4b63452d.672afc",
"name": "",
"sep": ",",
"hdrin": false,
"hdrout": "none",
"multi": "one",
"ret": "\\n",
"temp": "kind,price",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 600,
"y": 1080,
"wires": [
[
"859725fd.dc93d8"
]
]
},
{
"id": "1d857b8d.3a4014",
"type": "template",
"z": "4b63452d.672afc",
"name": "JS object",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "plain",
"template": "[\n {\n \"kind\": \"Apple\",\n \"price\": 100,\n \"origin\": \"Canada\"\n },\n {\n \"kind\": \"Orange\",\n \"price\": 120,\n \"origin\": \"USA\"\n },\n {\n \"kind\": \"Banana\",\n \"price\": 80,\n \"origin\": \"Philippines\"\n }\n]",
"output": "json",
"x": 430,
"y": 1080,
"wires": [
[
"66a37667.16ebd8"
]
]
},
{
"id": "859725fd.dc93d8",
"type": "debug",
"z": "4b63452d.672afc",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 780,
"y": 1080,
"wires": []
}
]

View File

@ -0,0 +1,99 @@
[
{
"id": "2ebdd51e.c5d17a",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Convert array of JavaScript objects to CSV with column name header",
"info": "CSV node can convert an array of JavaScript objects to multi-line CSV text with column name header at first line.",
"x": 390,
"y": 1200,
"wires": []
},
{
"id": "2b4d538d.ada07c",
"type": "inject",
"z": "4b63452d.672afc",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 260,
"y": 1260,
"wires": [
[
"3e5c9e8.5065b62"
]
]
},
{
"id": "db02c7be.0984e8",
"type": "csv",
"z": "4b63452d.672afc",
"name": "",
"sep": ",",
"hdrin": false,
"hdrout": "all",
"multi": "one",
"ret": "\\n",
"temp": "kind,price",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 600,
"y": 1260,
"wires": [
[
"61f8b772.ddb1f8"
]
]
},
{
"id": "3e5c9e8.5065b62",
"type": "template",
"z": "4b63452d.672afc",
"name": "JS object",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "plain",
"template": "[\n {\n \"kind\": \"Apple\",\n \"price\": 100,\n \"origin\": \"Canada\"\n },\n {\n \"kind\": \"Orange\",\n \"price\": 120,\n \"origin\": \"USA\"\n },\n {\n \"kind\": \"Banana\",\n \"price\": 80,\n \"origin\": \"Philippines\"\n }\n]",
"output": "json",
"x": 430,
"y": 1260,
"wires": [
[
"db02c7be.0984e8"
]
]
},
{
"id": "61f8b772.ddb1f8",
"type": "debug",
"z": "4b63452d.672afc",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 780,
"y": 1260,
"wires": []
}
]

View File

@ -0,0 +1,99 @@
[
{
"id": "2ebdd51e.c5d17a",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Convert array of JavaScript objects to CSV with column name header",
"info": "CSV node can convert an array of JavaScript objects to multi-line CSV text with column name header at first line.",
"x": 390,
"y": 1200,
"wires": []
},
{
"id": "2b4d538d.ada07c",
"type": "inject",
"z": "4b63452d.672afc",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 260,
"y": 1260,
"wires": [
[
"3e5c9e8.5065b62"
]
]
},
{
"id": "db02c7be.0984e8",
"type": "csv",
"z": "4b63452d.672afc",
"name": "",
"sep": ",",
"hdrin": false,
"hdrout": "all",
"multi": "one",
"ret": "\\n",
"temp": "kind,price",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 600,
"y": 1260,
"wires": [
[
"61f8b772.ddb1f8"
]
]
},
{
"id": "3e5c9e8.5065b62",
"type": "template",
"z": "4b63452d.672afc",
"name": "JS object",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "plain",
"template": "[\n {\n \"kind\": \"Apple\",\n \"price\": 100,\n \"origin\": \"Canada\"\n },\n {\n \"kind\": \"Orange\",\n \"price\": 120,\n \"origin\": \"USA\"\n },\n {\n \"kind\": \"Banana\",\n \"price\": 80,\n \"origin\": \"Philippines\"\n }\n]",
"output": "json",
"x": 430,
"y": 1260,
"wires": [
[
"db02c7be.0984e8"
]
]
},
{
"id": "61f8b772.ddb1f8",
"type": "debug",
"z": "4b63452d.672afc",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 780,
"y": 1260,
"wires": []
}
]

View File

@ -0,0 +1,200 @@
[
{
"id": "1ae28939.9f5fc7",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Send column name when reset property set",
"info": "CSV node can send column names at first or `reset` property exists in input message.",
"x": 310,
"y": 1540,
"wires": []
},
{
"id": "c16ad95b.4f9ac8",
"type": "inject",
"z": "4b63452d.672afc",
"name": "Apple",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 250,
"y": 1600,
"wires": [
[
"7f7bfc72.aed104"
]
]
},
{
"id": "870620b9.95343",
"type": "csv",
"z": "4b63452d.672afc",
"name": "",
"sep": ",",
"hdrin": false,
"hdrout": "once",
"multi": "one",
"ret": "\\n",
"temp": "kind,price",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 650,
"y": 1720,
"wires": [
[
"d960de42.619c7"
]
]
},
{
"id": "7f7bfc72.aed104",
"type": "template",
"z": "4b63452d.672afc",
"name": "JS object",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "plain",
"template": "{\n \"kind\": \"Apple\",\n \"price\": 100,\n \"origin\": \"Canada\"\n}",
"output": "json",
"x": 470,
"y": 1600,
"wires": [
[
"870620b9.95343"
]
]
},
{
"id": "d960de42.619c7",
"type": "debug",
"z": "4b63452d.672afc",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 830,
"y": 1720,
"wires": []
},
{
"id": "6f8296e.f95ca68",
"type": "inject",
"z": "4b63452d.672afc",
"name": "Orange",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 250,
"y": 1660,
"wires": [
[
"c37d0dfa.ec1ab"
]
]
},
{
"id": "c37d0dfa.ec1ab",
"type": "template",
"z": "4b63452d.672afc",
"name": "JS object",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "plain",
"template": "{\n \"kind\": \"Orange\",\n \"price\": 120,\n \"origin\": \"USA\"\n}\n",
"output": "json",
"x": 470,
"y": 1660,
"wires": [
[
"870620b9.95343"
]
]
},
{
"id": "35209fe2.16926",
"type": "inject",
"z": "4b63452d.672afc",
"name": "Banana & reset",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
},
{
"p": "reset",
"v": "",
"vt": "date"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 280,
"y": 1720,
"wires": [
[
"afd4e6b3.624a28"
]
]
},
{
"id": "afd4e6b3.624a28",
"type": "template",
"z": "4b63452d.672afc",
"name": "JS object",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "plain",
"template": "{\n \"kind\": \"Banana\",\n \"price\": 80,\n \"origin\": \"Philippines\"\n}",
"output": "json",
"x": 470,
"y": 1720,
"wires": [
[
"870620b9.95343"
]
]
}
]

View File

@ -0,0 +1,150 @@
[
{
"id": "195c168c.44f149",
"type": "inject",
"z": "4b63452d.672afc",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 260,
"y": 1900,
"wires": [
[
"b270564c.171908"
]
]
},
{
"id": "8ec8cf9e.103fa",
"type": "csv",
"z": "4b63452d.672afc",
"name": "",
"sep": ",",
"hdrin": true,
"hdrout": "none",
"multi": "one",
"ret": "\\n",
"temp": "",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 600,
"y": 1900,
"wires": [
[
"5c5254a8.bc562c"
]
]
},
{
"id": "b270564c.171908",
"type": "template",
"z": "4b63452d.672afc",
"name": "CSV data",
"field": "payload",
"fieldType": "msg",
"format": "text",
"syntax": "mustache",
"template": "kind,price,origin\nApple,100,Canada\nOrange,120,USA\nBanana,80,Philippines",
"output": "str",
"x": 430,
"y": 1900,
"wires": [
[
"8ec8cf9e.103fa"
]
]
},
{
"id": "1c7be442.6a4bdc",
"type": "debug",
"z": "4b63452d.672afc",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1090,
"y": 1900,
"wires": []
},
{
"id": "d3da7cfb.cf596",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Join parsed CSV message sequence using join node",
"info": "Parset CSV message sequence can be joined by join node.",
"x": 330,
"y": 1840,
"wires": []
},
{
"id": "a07c9e26.c84fd",
"type": "csv",
"z": "4b63452d.672afc",
"name": "",
"sep": ",",
"hdrin": "",
"hdrout": "none",
"multi": "one",
"ret": "\\n",
"temp": "kind,price",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 910,
"y": 1900,
"wires": [
[
"1c7be442.6a4bdc"
]
]
},
{
"id": "5c5254a8.bc562c",
"type": "join",
"z": "4b63452d.672afc",
"name": "",
"mode": "auto",
"build": "string",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 750,
"y": 1900,
"wires": [
[
"a07c9e26.c84fd"
]
]
}
]