Skip to content

Compare Datasets 比较数据集#

Compare Datasets 节点帮助您比较来自两个输入流的数据。

节点参数#

  1. 决定要比较哪些字段。在Input A Field 输入 A 字段中,输入您想从输入流 A 使用的字段名称。在Input B Field 输入 B 字段中,输入您想从输入流 B 使用的字段名称。
  2. 可选:您可以按多个字段进行比较。选择Add Fields to Match 添加要匹配的字段来设置更多比较。
  3. 选择如何处理数据集之间的差异。在When There Are Differences 当存在差异时,选择以下选项之一:
    • Use Input A Version 使用输入 A 版本:将输入流 A 视为真实来源。
    • Use Input B Version 使用输入 B 版本:将输入流 B 视为真实来源。
    • Use a Mix of Versions 使用混合版本:为不同字段使用不同的输入。
      • 使用Prefer 首选选择Input A Version 输入 A 版本Input B Version 输入 B 版本作为主要真实来源。
      • For Everything Except 除了所有内容外中输入作为例外的输入字段,从另一个输入源提取。要添加多个输入字段,请输入逗号分隔的列表。
    • Include Both Versions 包含两个版本:在输出中包含两个输入流,这可能会使结构更复杂。
  4. 决定是否使用Fuzzy Compare 模糊比较。打开时,比较将在比较字段时容忍小的类型差异。例如,数字 3 和字符串 3 在打开Fuzzy Compare 模糊比较时被视为相同,但在关闭时不会被视为相同。

理解项目比较#

项目比较是一个两阶段过程:

  1. n8n 检查您选择比较的字段值是否在两个输入之间匹配。
  2. 如果要比较的字段匹配,n8n 然后比较项目内的所有字段,以确定项目是否相同或不同。

节点选项#

使用节点Options 选项来完善您的比较或调整比较行为。

Fields to Skip Comparing 跳过比较的字段#

输入您想在比较中忽略的字段名称。

例如,如果您使用 person.language 作为Fields to Match 要匹配的字段比较下面的两个数据集,n8n 会返回它们为不同。如果您将 person.name 添加到Fields to Skip Comparing 跳过比较的字段,n8n 会返回它们为匹配。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
	// Input 1
	[
		{
			"person":
			{
				"name":	"Stefan",
				"language":	"de"
			}
		},
		{
			"person":
			{
				"name":	"Jim",
				"language":	"en"
			}
		},
		{
			"person":
			{
				"name":	"Hans",
				"language":	"de"
			}
		}
	]
	// Input 2
		[
		{
			"person":
			{
				"name":	"Sara",
				"language":	"de"
			}
		},
		{
			"person":
			{
				"name":	"Jane",
				"language":	"en"
			}
		},
		{
			"person":
			{
				"name":	"Harriet",
				"language":	"de"
			}
		}
	]

Disable Dot Notation 禁用点表示法#

是否禁止在字段名称中使用 parent.child 引用子字段(打开)或允许它(关闭,默认)。

Multiple Matches 多重匹配#

选择如何处理重复数据。默认是Include All Matches 包含所有匹配。您可以选择Include First Match Only 仅包含第一个匹配

例如,给定这两个数据集:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
	// Input 1
	[
		{
			"fruit": {
				"type": "apple",
				"color": "red"
			}
		},
				{
			"fruit": {
				"type": "apple",
				"color": "red"
			}
		},
				{
			"fruit": {
				"type": "banana",
				"color": "yellow"
			}
		}
	]
	// Input 2
	[
		{
			"fruit": {
				"type": "apple",
				"color": "red"
			}
		},
				{
			"fruit": {
				"type": "apple",
				"color": "red"
			}
		},
				{
			"fruit": {
				"type": "banana",
				"color": "yellow"
			}
		}
	]

n8n 在Same Branch 相同分支选项卡中返回三个项目。两个分支中的数据是相同的。

如果您选择Include First Match Only 仅包含第一个匹配,n8n 在Same Branch 相同分支选项卡中返回两个项目。两个分支中的数据是相同的,但 n8n 只返回匹配的"apple"项目的第一次出现。

理解输出#

有四个输出选项:

  • In A only Branch 仅在 A 中分支:包含仅在第一个输入中出现的数据。
  • Same Branch 相同分支:包含在两个输入中相同的数据。
  • Different Branch 不同分支:包含输入之间不同的数据。
  • In B only Branch 仅在 B 中分支:包含仅在第二个输出中出现的数据。

模板和示例#

Intelligent Email Organization with AI-Powered Content Classification for Gmail

by Niranjan G

View template details
Two way sync Pipedrive and MySQL

by n8n Team

View template details
Sync Google Sheets data with MySQL

by n8n Team

View template details
Browse Compare Datasets 比较数据集 integration templates, or search all templates