This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Sum of the column of the CSV file

I have a CSV file like below and I want to sum the columns 2 and column 3 and write the total at the end of the column as below:

Here is my file:

read,match,not_match
    human_file_0000003,5,2
    human_file_0000004,6,0
    human_file_0000005,6,9
    human_file_0000006,4,0
    human_file_0000007,2,0
    human_file_0000008,5,0
    human_file_0000009,3,0

And I want to output my file like below:

read,match,not_match
        human_file_0000003,5,2
        human_file_0000004,6,0
        human_file_0000005,6,9
        human_file_0000006,4,0
        human_file_0000007,2,0
        human_file_0000008,5,0
        human_file_0000009,3,0
                           31,11

In which you can see column 2 total is 31 and column 3 total is 11. Thanks in advance for your suggestion. I search for it but I can't find any solution for that.

csv sum

In that, they add column 2 and column 3. Here I want to separate the sum of the total in column 2 and the separate sum of the total in column 3.

1 answer

https://stackoverflow.com/a/28905692/58082

Log in to answer this question.