Count the Number of Duplicates

Example

Part of the data in Excel file mat.xlsx is as follows:

5

5

7

5

5

7

9

6

10

...

The task is to count the occurrence number of repeated numbers, and the results are as follows:

key

num

1

11

2

9

3

5

4

9

5

13

6

11

7

15

8

7

9

11

10

9

Write SPL script:


A

1

=file("mat.xlsx").xlsimport()

2

=A1.(#1).groups@n(~:key;count(~):num)

3

=file("result.xlsx").xlsexport@t(A2)

A1 Read the data of excel file

A2 Summarize the number (key), and add a column for the number of duplicate values (num)

A3 Export results to result.xlsx