Last active
September 19, 2024 02:12
-
-
Save scwood/bde5f0b11faf7d4220dc6c12f6711146 to your computer and use it in GitHub Desktop.
Journal export script for Mom
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
# Go to the download folder where the JSON file is, right click in the | |
# File Explorer, click open Terminal. Then run the below command: | |
# | |
# export_entries.ps1 data.json > entries.txt | |
# | |
# Note: make sure that the JSON file is valid, e.g. get rid of the object at | |
# the top of the file with the export date and etc. If your app changes their | |
# output structure the script will need to be updated. | |
param ( | |
[string]$journalPath | |
) | |
# Read the JSON file content | |
$jsonContent = Get-Content -Path $journalPath -Raw | |
# Convert JSON content to a PowerShell object | |
$journalData = $jsonContent | ConvertFrom-Json | |
# Loop over every entry and print out the fields we care about | |
foreach ($entry in $journalData.entries) { | |
$formattedDate = [datetime]::Parse($entry.created_at).ToString("yyyy-MM-dd") | |
Write-Output $formattedDate | |
Write-Output "" | |
Write-Output $entry.text | |
Write-Output "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment