Created
November 19, 2022 18:04
-
-
Save RickCarlino/9536bff8fcdae67f5ebfd9e926a7dc10 to your computer and use it in GitHub Desktop.
Daylio Journal Formatter ingests Daylio CSV export and produces Markdown / Gemtext
This file contains 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
require "csv" | |
require "date" | |
output = [] | |
File.open("raw.csv").each_line do |input_row| | |
begin | |
CSV.parse(input_row) do |(date, time, entry)| | |
if entry && date != "full_date" | |
a = "#{date} #{time}" | |
output.push([DateTime.parse(a), entry]) | |
end | |
end | |
end | |
end | |
output | |
.group_by{|(d,e)| d.jd} | |
.to_a | |
.sort{|(d,e)| d} | |
.map do |(date, entries)| | |
header = entries.first.first.strftime("# %m/%d/%Y").chomp | |
body = entries.sort { |(d,t)| d }.map { |(d,t)| puts d.strftime("\n%H:%M: #{t}").chomp } | |
puts "\n" + header + body.join() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment