How do I get the sum of numbers for each column in a csv file separately. Then select the top 3 column and place them in a new list in order?

Hope someone can help with example of blocks.
Best regards,

1 Like

Please elaborate the question more. Your title contains more text than the description itself.

This should get you an A+ :wink:
remember to quote your sources !!


1 Like

These blocks take row sums, not column sums.

You would have to flip the incoming table around its diagonal for those blocks to give you column sums.

Here is a sample that does column sums:

column_sums.aia (3.0 KB)
Non-numeric columns are regarded as zero values in the summation process.

Sorting and maximum picking are not covered here.


Now corrected :upside_down_face:

Dear TIMAI2,
Attachment log.csv (it is a csv with 48 columns x 336 rows.)
Sorry, I didn't describe it clearly before. The procesure as following..

Step1. Load csv file and split 48 column into 3 LIST as follow.
LIST_A_column index set [9,10,11,12,21,22,23,24,33,34,35,36,45,46,47,48]
LIST_B_column index set [5,6,7,8,17,18,19,20,29,30,31,32,41,42,43,44]
LIST_C_column index set [1,2,3,4,13,14,15,16,25,26,27,28,37,38,39,40]

Step2 :
Compare each Column Sum value of LIST_A_Column_Index and then select the top 4 Column Indexes and arrange them in order as LIST_A4_Column_Index [9,21,22,33]
Compare each Column Sum value of LIST_B_Column_Index and then select the top 4 Column Indexes and arrange them in order as LIST_B4_Column_Index [7,8,20,32]
Compare each Column Sum value of LIST_C_Column_Index and then select the top 4 Column Indexes and arrange them in order as LIST_C4_Column_Index [13,14,25,26]

Step3 :
[9,21,22,33] [7,8,20,32] [13,14,25,26] to be a new list and arrange in order
The answer should be : [7,8,9,13,14,20,21,22,25,26,32,33]

Could you help to support
log.csv (54.3 KB)
an .aia code ?

Thanks and best regards,


There is only one row in each of LIST_A / LIST_B / LIST_C ? These are csv rows...

e.g. LIST_A


How does this become?


and what about the other 333 rows ?

1 Like

I get the impression here that no attempt was made to normalize the log data.
This data needs some data modelling upstream.

What do the rows mean?
What do the groups of 4 columns mean?


Notes :
The meaning of the csv file as following.
*column : represents 48 sensors location index. (48 fixed!)
*row : 48 sensors value read in each time. (The number of rows in different csv file will not be fixed.)
*48 sensors are deployed in three areas LIST_A / LIST_B / LIST_C
LIST_A is the fixed combination of these 16 sensor numbers.
Same as…
LIST_B : [5,6,7,8,17,18,19,20,29,30,31,32,41,42,43,44] the fixed 16 sensor numbers.
LIST_C : [1,2,3,4,13,14,15,16,25,26,27,28,37,38,39,40] the fixed 16 sensor numbers.

*I want to find out the top 4 largest sum of sensing values in each area.
top 4 in LIST_A is [9,21,22,33]
top 4 in LIST_B is [7,8,20,32]
top 4 in LIST_C is [13,14,25,26]
--- I did the comparison using excel

*Then arrange the selected 12 sensor numbers from small to large as follows
LIST_top12 : [7,8,9,13,14,20,21,22,25,26,32,33] ---- the result I want

Thanks for your kind help.
Best regards,

Please refer to above.

Thanks & b.rgds,

Still cannot see how the above four numbers are the top 4 in this list:

Even with my simple grasp of mathematics I would expect [45,46,47,48]

[9,21,22,33] --- Take the top 4 of the 16 column sums from LIST_A . I got the result of sum comparison using excel. just for remind.
[9,10,11,12,21,22,23,24,33,34,35,36,45,46,47,48] -- This is not calculated, it is a fixed assigned sensor number in location LIST_A.

Best regards,

LIST_A : [9,10,11,12,21,22,23,24,33,34,35,36,45,46,47,48]
The goal is to find TOP 4 column sum index in the A/B/C
LIST_top12 : [7,8,9,13,14,20,21,22,25,26,32,33] ---- the result I want


Sorry, don't get it. :frowning:

Maybe someone else can understand what you want to achieve.....

Simply speaking I just want to find the column index of the top 12 in the 48 cloumn sum values in the CSV.
But the 48 column indexes are divided into 3 parts( A/B/C) .
LIST_A : [9,10,11,12,21,22,23,24,33,34,35,36,45,46,47,48] ---column index number
LIST_B : [5,6,7,8,17,18,19,20,29,30,31,32,41,42,43,44]
LIST_C : [1,2,3,4,13,14,15,16,25,26,27,28,37,38,39,40]
I need top 4 from LIST_A , LIST_B , LIST_C , then there are 12 column indexes in total.
Looking forward to hear from you soon.


It's not very clear for me, but if you want the top 4 values in a list you have to sort the list and keep the first 4 values.
Maybe it's better to solve one problem at a time

Hi patel,
attachment : 1. csv file 2. flow chart
log.csv (54.3 KB)
flow chart.pdf (465.2 KB)
Hope the attachment helps to understand.
Best regards,

I don't understand step 2,3,4

Here are some blocks to get you part way through, with top 4 selection by group.
You can assemble the results to your taste...

sensor_group_log.aia (28.4 KB)