Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Merging columns from a large CSV file

$
0
0

Hello all,

I am trying to find a way to merge the data from several columns from a CSV file and output the result to another CSV file.

The data I am working with is stored into a variable and looks like this (with many more columns and rows) :

"Time","Idle","System","smss","csrss#4","csrss#3","wininit","winlogon#3","services","lsass","lsm","svchost#11"
"04:04:20","172.41","1.09","0","0","0","0","0","1.56","1.41","0","0","0","0","0","0","0","0","0","0.16","0"
"04:04:30","163.55","0.31","0","0","0","0","0","1.25","3.43","0","0","0","0","0","0","0","0.16","0","0","0"

As you can see, some columns are numbered. I need to detect these, and add up the date from them.
The output would then look like this :

"Time","System","smss","csrss","wininit","winlogon","services","lsass","lsm","svchost"
"04:04:20","1.09","0","0","0","0","0","1.56","1.41","0","0","0","0","0","0","0","0"
"04:04:30","0.31","0","0","0","0","0","1.25","3.43","0","0","0","0","0","0","0","0.16"

In this case,
"csrss#4" and "csrss#3" (plus some others out of view here) were added up under the column "csrss". Same thing with "winlogon" and "svchost"
The column "idle", useless, was dropped in the process.

Would somebody have an idea about how to do this ?

Thanks a lot

Viewing all articles
Browse latest Browse all 6937

Trending Articles