View Single Post
Old 09-29-2017, 05:08 PM   #34
ermax
Senior Member
 
ermax's Avatar
 
Join Date: Sep 2017
Drives: 2022 BRZ Limited Silver
Location: Jacksonville, FL
Posts: 2,533
Thanks: 883
Thanked 2,049 Times in 1,191 Posts
Mentioned: 68 Post(s)
Tagged: 0 Thread(s)
As a simple work around for my inability to get the defogger to start stop logs I decided to write a simple PowerShell script that will take a log and then export individual logs containing just the samples where the defogger is turned on.

Split-Log.ps1:
Code:
param (
    [Parameter(Mandatory=$true)][string]$filename
)

$logNum = 0
$logStart = $false
$logSamples = @()

foreach ($sample in (ConvertFrom-Csv (Get-Content -Path $filename))) {
    if ($sample.defogger_sw -eq 1) {
        if($logStart -eq $false) {
            $logStart = $true
            $logNum++
            $logSamples += $sample
        } else {
            $logSamples += $sample
        }
    } elseif ($logStart -eq $true) {
        $logStart = $false
        $logSamples | Export-Csv -Path "$([IO.Path]::GetFileNameWithoutExtension($filename)).$($logNum)$([IO.Path]::GetExtension($filename))" -NoTypeInformation
        $logSamples = @()
    }
}

if ($logSamples.length) {
    Write-Host "Saving: $([IO.Path]::GetFileNameWithoutExtension($filename)).$($logNum)$([IO.Path]::GetExtension($filename))"
    $logSamples | Export-Csv -Path "$([IO.Path]::GetFileNameWithoutExtension($filename)).$($logNum)$([IO.Path]::GetExtension($filename))" -NoTypeInformation    
}
To run it you would do something like this:
Code:
Split-Log.ps1 -filename Log10.csv
It will then export logs for the the samples where the defogger is on and the files will be named Log10.1.scv, Log10.2.csv and so on. After it pulls out the relevant data you could then simply delete the original log. This is assuming you have named your defogger channel as deffoger_sw. You will have to edit the script if you are using some other name for your defogger channel. Hopefully this will help someone out there.

Last edited by ermax; 09-29-2017 at 10:02 PM.
ermax is offline   Reply With Quote