How to Judge Equality and Belongingness Between Sets

 

Example

There is an Excel file Book1.xlsx, and part of the data is as follows:

code

order

A

1

A

2

A

3

A

4

B

1

B

2

B

4

B

3

C

4

C

2

C

3

C

1

The data of Excel file standard1.xlsx is as follows:

order

1

2

3

4

The data of Excel file standard2.xlsx is as follows:

order

1

2

 

Example 1: Equality of sets

Of the same code in Book1, select all the data where the order column is exactly the same as the order column of standard1.

Write SPL script:


A

1

=file("Book1.xlsx").xlsimport@t()

2

=file("standard1.xlsx").xlsimport@t()

3

=A2.(order)

4

=A1.group(code).select(~.(order)==A3).conj()

A1 Read the Excel data 

A2 Read the Excel data 

A3 The order data in standard1 

A4 Group the data of Book1 by code and find the data whose order column in each group is equal to the data of A3. The results are as follows:

code

order

A

1

A

2

A

3

A

4

 

Example 2: Belonging to or Containing

Of the same code in Book1, select all data where order column contains the order column of standard2. 

Write SPL script: 


A

1

=file("Book1.xlsx").xlsimport@t()

2

=file("standard2.xlsx").xlsimport@t()

3

=A2.(order)

4

=A1.group(code).select(~.(order).pos@c(A3)).conj()

A1 Read the Excel data 

A2 Read the Excel data 

A3 The order data in standard2 

A4 Group the data of Book1 by code and select all the data whose order columns in each group contain the data of A3. The results are as follows: 

code

order

A

1

A

2

A

3

A

4

B

1

B

2

B

4

B

3