Last active
November 28, 2022 01:41
-
-
Save mavaddat/cdf91d2ac6b5cabc253aff871713660b to your computer and use it in GitHub Desktop.
Convert Blood Pressures from Google Fit Takeout Files to CSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$TakeoutExtractedPath = "C:\Users\mavad\AppData\Local\Temp\MicrosoftEdgeDownloads\6acfbb86-1c53-4929-9741-118ff28d0db0\Takeout\Fit\All Data" | |
$UtcOffset = [System.TimeZone]::CurrentTimeZone.GetUtcOffset(0).Hours | |
(Get-ChildItem -Path $TakeoutExtractedPath -Filter *blood* -Recurse | ForEach-Object { | |
Get-Content -Path $_ | ConvertFrom-Json | Select-Object -ExpandProperty 'Data Points' | |
} | ForEach-Object { | |
[pscustomobject]@{ | |
Date = [datetime]::UnixEpoch.AddMicroseconds(($_.endTimeNanos * 1E-3)).AddHours($UtcOffset) | |
Systolic = $_.fitValue.value.fpVal[0]; | |
Diastolic = $_.fitValue.value.fpVal[1] | |
} | Write-Output | |
} | |
) | Select-Object Date, Systolic, Diastolic -Unique | ConvertTo-Csv | Out-File -FilePath ($temp = New-TemporaryFile) | |
Write-Host "Wrote CSV to" $temp.FullName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment