使用 JavaScript 和 Python 生成并拆分样本数据记录
这是一个Engineering、Miscellaneous、Multimodal AI领域的自动化工作流,包含 7 个节点。主要使用 Code、SplitOut、ManualTrigger 等节点。 使用 JavaScript 和 Python 生成并拆分样本数据记录
- •无特殊前置要求,导入即可使用
使用的节点 (7 个)
{
"meta": {
"instanceId": "ad0113c344ee237399e44e9f11798b05baeb83a6196d514a9ae9d2ad71c3b5c9",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "934a8c2f-845f-4f88-8355-48ef17e50f32",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1120,
1984
],
"parameters": {
"color": 7,
"width": 1696,
"height": 1056,
"content": "### 使用代码创建样本记录并在 n8n 中拆分(代码 + 拆分输出)"
},
"typeVersion": 1
},
{
"id": "34f6b8c5-171b-4027-907b-cc8a41bd75a4",
"name": "便签 10",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1552,
1984
],
"parameters": {
"width": 400,
"height": 1056,
"content": ""
},
"typeVersion": 1
},
{
"id": "2dab6b4d-2d05-4294-8d6d-620513a777fc",
"name": "生成数据 JavaScript",
"type": "n8n-nodes-base.code",
"position": [
-480,
2368
],
"parameters": {
"jsCode": "// In n8n Code node, \"items\" is an array of input objects\n// You must return an array of items at the end\n\nreturn items.map(item => {\n const arr = [];\n\n for (let i = 0; i < 20; i++) {\n arr.push({\n index: i,\n num: i + 1,\n test: \"asdasd\"\n });\n }\n\n // attach to item.json\n item.json.barr = arr;\n return item;\n});\n"
},
"typeVersion": 2
},
{
"id": "c12e4e24-e1bd-4f32-98fd-876d91e79661",
"name": "生成数据 Python",
"type": "n8n-nodes-base.code",
"position": [
-480,
2560
],
"parameters": {
"language": "python",
"pythonCode": "arr = [{\"index\": i, \"num\": i + 1, \"test\": \"asdasd\"} for i in range(20)]\nreturn [{\"json\": {\"barr\": arr}}]\n"
},
"typeVersion": 2
},
{
"id": "5128ea0a-8d3d-49d1-bba2-102881725941",
"name": "启动工作流",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-848,
2368
],
"parameters": {},
"typeVersion": 1
},
{
"id": "50e53b82-2556-4f8a-9b41-ed911d7319cc",
"name": "拆分输出 JavaScript",
"type": "n8n-nodes-base.splitOut",
"position": [
-272,
2368
],
"parameters": {
"options": {},
"fieldToSplitOut": "barr"
},
"typeVersion": 1
},
{
"id": "ee5064bc-a511-4d63-9cef-67ff348d76a2",
"name": "拆分输出 Python",
"type": "n8n-nodes-base.splitOut",
"position": [
-272,
2560
],
"parameters": {
"options": {},
"fieldToSplitOut": "barr"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Start Workflow": {
"main": [
[
{
"node": "Generate Data Javascript",
"type": "main",
"index": 0
},
{
"node": "Generate Data Python",
"type": "main",
"index": 0
}
]
]
},
"Generate Data Python": {
"main": [
[
{
"node": "Split Out Python",
"type": "main",
"index": 0
}
]
]
},
"Generate Data Javascript": {
"main": [
[
{
"node": "Split Out Javascript",
"type": "main",
"index": 0
}
]
]
}
}
}如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个中级难度的工作流,适用于Engineering、Miscellaneous、Multimodal AI等场景。适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Robert Breen
@rbreenProfessional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.
分享此工作流