Created
May 18, 2011 00:27
-
-
Save bloom/977766 to your computer and use it in GitHub Desktop.
Import to Day One Journal app from MacJournal Export
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 "open3" | |
def readfile(file) | |
f = File.open(file) | |
lines = f.readlines("\n\n\n\n") | |
lines.each do |line| | |
fields = line.scan(/\s+Date:\s([^\n]+)$\s+Topic:\s([^\n]+)\n(.*)/m) | |
date = fields[0][0].strip | |
topic = fields[0][1].strip | |
text = topic + "\n" + fields[0][2].strip | |
puts date | |
puts text | |
puts "-------------------------------------------------------------" | |
Open3.popen3("/Applications/Day One.app/Contents/MacOS/dayone", "-d=\"#{date}\"", "new") do |stdin, stdout, stderr| | |
stdin.write(text) | |
stdin.close_write | |
puts stdout.read | |
end | |
puts "-------------------------------------------------------------" | |
end | |
end | |
readfile(ARGV[0]) |
Author
bloom
commented
Feb 8, 2012
via email
Fantastic, thank you. I'm actually testing our built-in importer for MacJournal right now.
…On Tuesday, February 7, 2012 at 6:05 PM, Kevin McKenzie wrote:
I had some serious issues getting this to work, so I wrote my own in python. See https://github.com/Tam-Lin/MacJournaltoDayOne---Python.
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/977766
The built in importer does not work. It returns: The operation could not be completed. No other information is available about the problem.
Can anyone help?
What is the latest on the MacJournal importer? Will it import the tags and photos used in MacJournal entries?
Thanks!
Thanks for putting this up. The built-in import of MacJournal files dates the entries by creation date, rather than the MacJournal internal date. This gist addresses this, which is nice. However, with the newest version of Day One (1.10.2) the executable you refer to in line 18 does not work. I changed this line to:
Open3.popen3("/usr/local/bin/dayone", "-d=\"#{date}\"", "new") do |stdin, stdout, stderr|
And this appears to solve it.
I've updated @Tam-Lin's script for Day One 2.x. Instructions here.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment