T.log to csv convertor

Hi,

I am looking forward to understand how to convert t.log file generated by the drone after the flight to a text or csv file. Also I tried to achieve this using Flight Log convertor. But as my converted csv file has too many irreilvent data for my application I was thinking is there an sorting of the usefull entities possible befor converting it to csv file?

It would be great to learn a way to tackle this. I am looking forward to the discussion.

I guess you could first convert it to txt, then modify this Powershell code to split the log into multiple CSV files, one per message type. Problem is you don’t have the handy FMT lines at the start telling you how each message type will look like.

Add-Type -AssemblyName System.Windows.Forms
$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
    InitialDirectory = [Environment]::GetFolderPath('UserProfile')
    Filter = 'Log Files|*.log|Text Files|*.txt|All Files|*.*'
    Title = "Select Ardupilot Logfile to Split"
}
$null = $FileBrowser.ShowDialog()
$FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{
    Description = "Select Output Folder (Warning: There will be many CSV files)"
}
$null = $FolderBrowser.ShowDialog()
$LogPath = $FileBrowser.FileName
$OutPath = $FolderBrowser.SelectedPath
Write-Host "That's going to take a while....."
$FMTLinesReg = (Get-Content $LogPath | Select-String '(FMT,.*)') | Select-Object -Skip 1
ForEach ($item in $FMTLinesReg) {
    [array]$contentary = $null
    $LoopLine = $item.ToString()
    $LoopModuleAry = $LoopLine | Select-String -Pattern '(FMT, [0-9]+, [0-9]+, )([\w]+), ([\w]+), (.*)'
    $LoopModuleStr = $LoopModuleAry.Matches.Groups[2].Value
    $LoopLineHeader = $LoopModuleAry.Matches.Groups[4].Value
    $LoopFilePath = ($OutPath + "\" + $LoopModuleStr + ".csv")
    New-Item -Path $LoopFilePath -Type file
    Add-Content -Path $LoopFilePath -Value $LoopLineHeader
    $LoopLinesReg = Get-Content $LogPath | Select-String -Pattern "^($($LoopModuleStr), )(.*)$"
    ForEach ($item1 in $LoopLinesReg) {
        $itemtrk = $item1 | Select-String -Pattern "^($($LoopModuleStr), )(.*)$"
        $itemtrk = $itemtrk.Matches.Groups[2].Value -replace '\s+', ''
        [array]$contentary += $itemtrk
    }
    Add-Content -Path $LoopFilePath -Value ($contentary -join "`n")
}

Hey Oli,

Thank you for the information. But my goal is to undertand how do I convert
a. tlog to txt file and then use this text file and sort only useful entities into csv file and then this csv file would be used to generate an overall report in pdf format showing the details of flight.

Mission Planner > Telemetry Logs > Tlog to Kml or Graph > Convert to Text

That’s the hard part. Might be possible with a modified script similar to the one posted above, or you can check the mavlogdump.py from pymavlink, might be possible with it as well.