📋 サンプルフロー(クリックで展開)
参照元:Node-REDエディター内サンプルフロー
[
{
"id": "60e740b9c7fe662f",
"type": "tab",
"label": "csv",
"disabled": false,
"info": "",
"env": []
},
{
"id": "330f4888.cccb28",
"type": "inject",
"z": "60e740b9c7fe662f",
"name": "",
"props": [{"p": "payload"}, {"p": "topic", "vt": "str"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 270,
"y": 160,
"wires": [["ed11f8d6.5e3c88"]]
},
{
"id": "a0288b44.71d488",
"type": "csv",
"z": "60e740b9c7fe662f",
"name": "",
"spec": "rfc",
"sep": ",",
"hdrin": "",
"hdrout": "none",
"multi": "one",
"ret": "\\r\\n",
"temp": "",
"skip": 0,
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 610,
"y": 160,
"wires": [["369cbe42.4af9f2"]]
},
{
"id": "ed11f8d6.5e3c88",
"type": "template",
"z": "60e740b9c7fe662f",
"name": "CSV data",
"field": "payload",
"fieldType": "msg",
"format": "text",
"syntax": "mustache",
"template": "Apple,100,Canada\nOrange,120,USA\nBanana,80,Philippines",
"output": "str",
"x": 440,
"y": 160,
"wires": [["a0288b44.71d488"]]
},
{
"id": "369cbe42.4af9f2",
"type": "debug",
"z": "60e740b9c7fe662f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 790,
"y": 160,
"wires": []
},
{
"id": "783cfaa6.52fbe4",
"type": "comment",
"z": "60e740b9c7fe662f",
"name": "Example 1: Parse CSV (default column names, messages)",
"info": "",
"x": 380,
"y": 100,
"wires": []
},
{
"id": "98c9d44d.4457b8",
"type": "inject",
"z": "60e740b9c7fe662f",
"name": "",
"props": [{"p": "payload"}, {"p": "topic", "vt": "str"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 270,
"y": 360,
"wires": [["65476517.3d760c"]]
},
{
"id": "76df98f7.0dcd08",
"type": "csv",
"z": "60e740b9c7fe662f",
"name": "",
"spec": "rfc",
"sep": ",",
"hdrin": "",
"hdrout": "none",
"multi": "mult",
"ret": "\\r\\n",
"temp": "",
"skip": 0,
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 610,
"y": 360,
"wires": [["557979e0.e6b588"]]
},
{
"id": "65476517.3d760c",
"type": "template",
"z": "60e740b9c7fe662f",
"name": "CSV data",
"field": "payload",
"fieldType": "msg",
"format": "text",
"syntax": "mustache",
"template": "Apple,100,Canada\nOrange,120,USA\nBanana,80,Philippines",
"output": "str",
"x": 440,
"y": 360,
"wires": [["76df98f7.0dcd08"]]
},
{
"id": "557979e0.e6b588",
"type": "debug",
"z": "60e740b9c7fe662f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 790,
"y": 360,
"wires": []
},
{
"id": "187f4ab3.4c9ab5",
"type": "comment",
"z": "60e740b9c7fe662f",
"name": "Example 2: Parse CSV (default column names, array)",
"info": "",
"x": 360,
"y": 300,
"wires": []
},
{
"id": "1216e95b.1b1e87",
"type": "inject",
"z": "60e740b9c7fe662f",
"name": "",
"props": [{"p": "payload"}, {"p": "topic", "vt": "str"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 280,
"y": 540,
"wires": [["e41ffbbc.de2ed8"]]
},
{
"id": "286828bc.9233c8",
"type": "csv",
"z": "60e740b9c7fe662f",
"name": "",
"spec": "rfc",
"sep": ",",
"hdrin": "",
"hdrout": "none",
"multi": "one",
"ret": "\\r\\n",
"temp": "kind,price,origin",
"skip": 0,
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 620,
"y": 540,
"wires": [["9d8218c.5550ee8"]]
},
{
"id": "e41ffbbc.de2ed8",
"type": "template",
"z": "60e740b9c7fe662f",
"name": "CSV data",
"field": "payload",
"fieldType": "msg",
"format": "text",
"syntax": "mustache",
"template": "Apple,100,Canada\nOrange,120,USA\nBanana,80,Philippines",
"output": "str",
"x": 450,
"y": 540,
"wires": [["286828bc.9233c8"]]
},
{
"id": "9d8218c.5550ee8",
"type": "debug",
"z": "60e740b9c7fe662f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 800,
"y": 540,
"wires": []
},
{
"id": "aaa1ee8f.21e2c",
"type": "comment",
"z": "60e740b9c7fe662f",
"name": "Example 3: Parse CSV (specified column names)",
"info": "",
"x": 350,
"y": 480,
"wires": []
},
{
"id": "24093558.0315aa",
"type": "inject",
"z": "60e740b9c7fe662f",
"name": "",
"props": [{"p": "payload"}, {"p": "topic", "vt": "str"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 280,
"y": 720,
"wires": [["80abaee1.5fa7f"]]
},
{
"id": "d4d2ca3f.1d9488",
"type": "csv",
"z": "60e740b9c7fe662f",
"name": "",
"spec": "rfc",
"sep": ",",
"hdrin": true,
"hdrout": "none",
"multi": "one",
"ret": "\\r\\n",
"temp": "",
"skip": 0,
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 620,
"y": 720,
"wires": [["b52791c3.08967"]]
},
{
"id": "80abaee1.5fa7f",
"type": "template",
"z": "60e740b9c7fe662f",
"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": 450,
"y": 720,
"wires": [["d4d2ca3f.1d9488"]]
},
{
"id": "b52791c3.08967",
"type": "debug",
"z": "60e740b9c7fe662f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 800,
"y": 720,
"wires": []
},
{
"id": "85091361.85644",
"type": "comment",
"z": "60e740b9c7fe662f",
"name": "Example 4: Parse CSV (first row as column names)",
"info": "",
"x": 360,
"y": 660,
"wires": []
},
{
"id": "8ca41fee.3303d",
"type": "inject",
"z": "60e740b9c7fe662f",
"name": "",
"props": [{"p": "payload"}, {"p": "topic", "vt": "str"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 290,
"y": 900,
"wires": [["c466905b.e8c61"]]
},
{
"id": "65146d20.d78204",
"type": "csv",
"z": "60e740b9c7fe662f",
"name": "",
"spec": "rfc",
"sep": ",",
"hdrin": false,
"hdrout": "none",
"multi": "one",
"ret": "\\r\\n",
"temp": "kind,price",
"skip": 0,
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 630,
"y": 900,
"wires": [["92e99e67.a37d8"]]
},
{
"id": "c466905b.e8c61",
"type": "template",
"z": "60e740b9c7fe662f",
"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": 460,
"y": 900,
"wires": [["65146d20.d78204"]]
},
{
"id": "92e99e67.a37d8",
"type": "debug",
"z": "60e740b9c7fe662f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 810,
"y": 900,
"wires": []
},
{
"id": "9e93169c.b763a8",
"type": "comment",
"z": "60e740b9c7fe662f",
"name": "Example 5: Convert object to CSV",
"info": "",
"x": 310,
"y": 840,
"wires": []
},
{
"id": "bd0d82ed.7b28",
"type": "inject",
"z": "60e740b9c7fe662f",
"name": "",
"props": [{"p": "payload"}, {"p": "topic", "vt": "str"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 280,
"y": 1060,
"wires": [["1d857b8d.3a4014"]]
},
{
"id": "66a37667.16ebd8",
"type": "csv",
"z": "60e740b9c7fe662f",
"name": "",
"spec": "rfc",
"sep": ",",
"hdrin": false,
"hdrout": "none",
"multi": "one",
"ret": "\\r\\n",
"temp": "kind,price",
"skip": 0,
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 620,
"y": 1060,
"wires": [["859725fd.dc93d8"]]
},
{
"id": "1d857b8d.3a4014",
"type": "template",
"z": "60e740b9c7fe662f",
"name": "JS array",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "plain",
"template": "[\n {\"kind\": \"Apple\", \"price\": 100, \"origin\": \"Canada\"},\n {\"kind\": \"Orange\", \"price\": 120, \"origin\": \"USA\"},\n {\"kind\": \"Banana\", \"price\": 80, \"origin\": \"Philippines\"}\n]",
"output": "json",
"x": 450,
"y": 1060,
"wires": [["66a37667.16ebd8"]]
},
{
"id": "859725fd.dc93d8",
"type": "debug",
"z": "60e740b9c7fe662f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 800,
"y": 1060,
"wires": []
},
{
"id": "e89019c5.70ae78",
"type": "comment",
"z": "60e740b9c7fe662f",
"name": "Example 6: Convert array to CSV",
"info": "",
"x": 310,
"y": 1000,
"wires": []
},
{
"id": "2b4d538d.ada07c",
"type": "inject",
"z": "60e740b9c7fe662f",
"name": "",
"props": [{"p": "payload"}, {"p": "topic", "vt": "str"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 280,
"y": 1220,
"wires": [["3e5c9e8.5065b62"]]
},
{
"id": "db02c7be.0984e8",
"type": "csv",
"z": "60e740b9c7fe662f",
"name": "",
"spec": "rfc",
"sep": ",",
"hdrin": false,
"hdrout": "all",
"multi": "one",
"ret": "\\r\\n",
"temp": "kind,price",
"skip": 0,
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 620,
"y": 1220,
"wires": [["61f8b772.ddb1f8"]]
},
{
"id": "3e5c9e8.5065b62",
"type": "template",
"z": "60e740b9c7fe662f",
"name": "JS array",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "plain",
"template": "[\n {\"kind\": \"Apple\", \"price\": 100, \"origin\": \"Canada\"},\n {\"kind\": \"Orange\", \"price\": 120, \"origin\": \"USA\"},\n {\"kind\": \"Banana\", \"price\": 80, \"origin\": \"Philippines\"}\n]",
"output": "json",
"x": 450,
"y": 1220,
"wires": [["db02c7be.0984e8"]]
},
{
"id": "61f8b772.ddb1f8",
"type": "debug",
"z": "60e740b9c7fe662f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 800,
"y": 1220,
"wires": []
},
{
"id": "2ebdd51e.c5d17a",
"type": "comment",
"z": "60e740b9c7fe662f",
"name": "Example 7: Convert array to CSV with header",
"info": "",
"x": 350,
"y": 1160,
"wires": []
}
]
区切り文字: ,
カラム名: (空白 = col1, col2, col3...を自動生成)
1行目をカラム名に: OFF
出力形式: 1行毎にメッセージを送信
入力: "Apple,100,Canada\nOrange,120,USA\nBanana,80,Philippines"
出力1: {col1: "Apple", col2: "100", col3: "Canada"}
出力2: {col1: "Orange", col2: "120", col3: "USA"}
出力3: {col1: "Banana", col2: "80", col3: "Philippines"}
区切り文字: ,
出力形式: 単一の配列メッセージとして出力
入力: "Apple,100,Canada\nOrange,120,USA\nBanana,80,Philippines"
出力: [
{col1: "Apple", col2: "100", col3: "Canada"},
{col1: "Orange", col2: "120", col3: "USA"},
{col1: "Banana", col2: "80", col3: "Philippines"}
]
区切り文字: ,
カラム名: kind,price,origin
1行目をカラム名に: OFF
入力: "Apple,100,Canada\nOrange,120,USA"
出力1: {kind: "Apple", price: "100", origin: "Canada"}
出力2: {kind: "Orange", price: "120", origin: "USA"}
区切り文字: ,
1行目をカラム名に: ON
入力: "kind,price,origin\nApple,100,Canada\nOrange,120,USA"
出力1: {kind: "Apple", price: "100", origin: "Canada"} ← 先頭行はスキップ
出力2: {kind: "Orange", price: "120", origin: "USA"}
カラム名: kind,price ← originは除外
ヘッダー行: なし
入力: {kind: "Apple", price: 100, origin: "Canada"}
出力: "Apple,100\n"
カラム名: kind,price
ヘッダー行: 常に出力
入力: [
{kind: "Apple", price: 100},
{kind: "Orange", price: 120}
]
出力: "kind,price\nApple,100\nOrange,120\n"
MQTTノード(センサーデータ受信)
↓
Functionノード(データ整形)
↓
CSVノード(CSV形式に変換)
↓
File Appendノード(ファイルに追記)
用途: IoTセンサーからのデータをCSVファイルに記録
File Inノード(config.csv読み込み)
↓
CSVノード(パース、配列出力)
↓
Changeノード(フロー変数に保存)
用途: 外部CSVファイルから設定値を読み込み
HTTPリクエスト or DB照会
↓
Functionノード(データ集計)
↓
CSVノード(ヘッダー付きCSV生成)
↓
Emailノード or HTTP Responseノード
用途: 日次レポートをCSV形式で生成・送信
File Inノード(外部CSVファイル)
↓
CSVノード(パース)
↓
Switchノード(フィルタリング)
↓
Joinノード(再結合)
↓
CSVノード(新形式で生成)
↓
File Outノード(変換後ファイル出力)
用途: CSVファイルの形式変換、フィルタリング、加工