Find the Maximum and Minimum Values

Find locations

The Excel file book1.xlsx of material percentage is shown in the figure below:

..

Every two columns in the file form a group. The odd-numbered column is the material name, and the even-numbered column is the material percentage. Now we need to find the name of material with the largest percentage in each row.

Write SPL script:


A

1

=file("e:/work/book1.xlsx").xlsimport@w()

2

=A1.to(2,).(~.step(2,1)(~.step(2,2).pmax()))

 

A1 Read the data in book1.xlsx, the @w option means to read the data as a sequence of sequences.

 

A2 Loop through each row of the data sequence starting from the second row in A1. ~.step(2,2).pmax()means to take a value every two columns starting from the second column, namely Column 2, 4, 6......The taken values of the columns form a sequence, and then the sequence number of the maximum value in the sequence is taken out. In the same way, ~.step(2,1) means to take a value every two columns starting from the first column, namely Column 1, 3, 5...... The taken values of the columns form a sequence, and then the value corresponding to the sequence number of maximum value is taken out of this sequence.

Find members

There is a list of months in book1, in which every month will appear for indefinite times. The screenshot of the data is as follows:

..

Now we need to find the month with the least number of occurrences, and if there are more than one month, all of them will be found.

 

Write SPL script:


A

1

=T("e:/work/book1.xlsx")

2

=A1.group(Months).minp@a(~.count()).(~.Months)

 

A1 Read the data in book1.xlsx

 

A2 After grouping the data by Months, select the group with the smallest number of members in the group and return the Months of each group. The @a option means to select all groups that meet the condition.