Skip to main content
Solved

I have a csv file where I want to calculate the sum of a respective attribute which have the same ID. In the example below I want to sum the values of v2 and add it in the correct place for id = 22, then go onto the next "group", thanks!


id,v1,v2,v3,v4,v5

22,hi,hi,1,2,3

22,hi,hi,1,2,3

22,,,,,

33,hi,hi,2,3,4

33,hi,hi,2,3,4

33,hi,hi,2,3,4

33,,,,,

44,no,no,5,5,5

44,no,no,5,5,5

44,no,no,5,5,5

44,no,no,5,5,5

44,no,no,5,5,5

44,,,,,

Best answer by nielsgerrits

nielsgerrits wrote:

I probably do not understand what you need. Can you add you expected output?

I still do not understand why one would want this :D but the attached workspace produces what you asked for.

View original
Did this help you find an answer to your question?

6 replies

nielsgerrits
VIP
Forum|alt.badge.img+54

You can do this using the StatisticsCalculator. Group by id.


  • Author
  • October 13, 2023

Thanks! But how do I place the values found in the empty columns in the final row of each "group"?


nielsgerrits
VIP
Forum|alt.badge.img+54
stewartgr wrote:

Thanks! But how do I place the values found in the empty columns in the final row of each "group"?

I probably do not understand what you need. Can you add you expected output?


  • Author
  • October 13, 2023
nielsgerrits wrote:

I probably do not understand what you need. Can you add you expected output?

id,v1,v2,v3,v4,v5

22,hi,hi,1,2,3

22,hi,hi,1,2,3

22,,,sumv2,summv3,sumv4,sumv5

33,hi,hi,2,3,4

33,hi,hi,2,3,4

33,hi,hi,2,3,4

33,,,sumv2,summv3,sumv4,sumv5

44,no,no,5,5,5

44,no,no,5,5,5

44,no,no,5,5,5

44,no,no,5,5,5

44,no,no,5,5,5

44,,,sumv2,summv3,sumv4,sumv5


nielsgerrits
VIP
Forum|alt.badge.img+54
  • Best Answer
  • October 13, 2023
nielsgerrits wrote:

I probably do not understand what you need. Can you add you expected output?

I still do not understand why one would want this :D but the attached workspace produces what you asked for.


  • Author
  • October 13, 2023
nielsgerrits wrote:

I probably do not understand what you need. Can you add you expected output?

Thank you very much! Is part of a larger system which has its requirements, odd as they may be.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings