I am trying to combined data in a csv file. The data looks like:
colIP,colPartition,colPartitionSize,colPartitionFree
10.160.0.10,C:,8400,4600
10.160.0.11,C:,19500,16000
10.160.0.11,D:,185500,97700
10.160.0.12,C:,19500,15100
10.160.0.12,D:,48200,45900
What I am looking for is the deletion of the 2nd column, and then for all the rows who are the same in the first field, a sum of the 3rd and 4th fields. There could be 1 to 4 rows with the same data in field 1. Output should look like.
colIP,colPartitionSize,colPartitionFree
10.160.0.10,8400,4600
10.160.0.11,205000,113700
10.160.0.12,67700,61000
If this were columns I think I could do it, but since it's rows I'm not sure of the SQL.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.