Grouping/Sum CSV content

Welcome Forums General PowerShell Q&A Grouping/Sum CSV content

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
4 months ago.

  • Author
    Posts
  • #130812

    Participant
    Topics: 5
    Replies: 3
    Points: 61
    Rank: Member

    Hi All,

    I have an imported CSV file, example:
    Project, StartDate, StartTime, EndDate, EndTime, Duration
    Project 1, 19122018, 16:39:26, 19122018, 16:39:28, 00:01.8
    Project 2, 19122018, 16:39:28, 19122018, 16:39:29, 00:00.3
    Project 3, 19122018, 16:39:29, 19122018, 16:39:29, 00:00.4
    Project 4, 19122018, 16:39:29, 19122018, 16:39:29, 00:00.3
    Project 5, 19122018, 16:39:29, 19122018, 16:39:30, 00:00.3
    Project 6, 19122018, 16:39:30, 19122018, 16:39:30, 00:00.3
    Project 1, 19122018, 16:39:30, 19122018, 16:39:31, 00:00.5

    Project and StartDate can occur multiple times, are subject to change and will not be known ahead of time.
    I am trying to determine the total duration of each project on each day. I am encountering an issue as the duration is imported as a string rather then a timespan or similar, this is preventing me from performing a sum.

    The below is as far as I was able to get.

    $output = (Import-CSV -Path $script:csvPath -Delimiter ",") | Group-Object -property StartDate,Project
    
    foreach ($name in $output)
    {
        write-host $name.name "," $name.Group.Duration
    }
    

    Is anyone able to suggest a way to achieve the desired result?

    Thanks in advance

  • #131100

    Participant
    Topics: 1
    Replies: 1264
    Points: 1,381
    Helping Hand
    Rank: Community Hero

The topic ‘Grouping/Sum CSV content’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort