Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Import to Day One Journal app from MacJournal Export
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])
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 18, 2011

Heres a sample text file from a MacJournal export:

Date:   March 14, 2009 3:00 PM
Topic:  Rexburg Idaho

Last night we did

Date:   March 15, 2009 3:00 PM
Topic:  Lazy Sunday

Jana woke up

Owner

ghost commented May 18, 2011

Heres a sample text file from a MacJournal export:

Date:   March 14, 2009 3:00 PM
Topic:  Rexburg Idaho

Last night we did

Date:   March 15, 2009 3:00 PM
Topic:  Lazy Sunday

Jana woke up

@karthik

This comment has been minimized.

Show comment
Hide comment
@karthik

karthik Sep 1, 2011

Can you give us an example of how to run this? Also, what format should I export my macjournal in?

karthik commented Sep 1, 2011

Can you give us an example of how to run this? Also, what format should I export my macjournal in?

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Oct 13, 2011

We're working on a fully supported Import function. Sorry I'm not able to assist on this one right now.

Owner

ghost commented Oct 13, 2011

We're working on a fully supported Import function. Sorry I'm not able to assist on this one right now.

@gennaios

This comment has been minimized.

Show comment
Hide comment
@gennaios

gennaios Jan 6, 2012

any chance there could be a way to import MacJournal (or other) CSV? Not so good at ruby and it seems like it wouldn't be that much work but it could take a while to figure out. :)

gennaios commented Jan 6, 2012

any chance there could be a way to import MacJournal (or other) CSV? Not so good at ruby and it seems like it wouldn't be that much work but it could take a while to figure out. :)

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jan 20, 2012

Owner

ghost commented Jan 20, 2012

@karthik

This comment has been minimized.

Show comment
Hide comment
@karthik

karthik Jan 20, 2012

Perfect, thank you!

karthik commented Jan 20, 2012

Perfect, thank you!

@gennaios

This comment has been minimized.

Show comment
Hide comment
@gennaios

gennaios Jan 20, 2012

cool. I was able to do it with Excel and Applescript. worked great.

cool. I was able to do it with Excel and Applescript. worked great.

@ghost

This comment has been minimized.

Show comment
Hide comment
@Tam-Lin

This comment has been minimized.

Show comment
Hide comment
@Tam-Lin

Tam-Lin Feb 8, 2012

I had some serious issues getting this to work, so I wrote my own in python. See https://github.com/Tam-Lin/MacJournaltoDayOne---Python.

Tam-Lin commented Feb 8, 2012

I had some serious issues getting this to work, so I wrote my own in python. See https://github.com/Tam-Lin/MacJournaltoDayOne---Python.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 8, 2012

Owner

ghost commented Feb 8, 2012

@AsafKeller

This comment has been minimized.

Show comment
Hide comment
@AsafKeller

AsafKeller Aug 28, 2012

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?

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?

@PolishedStaple

This comment has been minimized.

Show comment
Hide comment
@PolishedStaple

PolishedStaple May 25, 2014

What is the latest on the MacJournal importer? Will it import the tags and photos used in MacJournal entries?

Thanks!

What is the latest on the MacJournal importer? Will it import the tags and photos used in MacJournal entries?

Thanks!

@kmlawson

This comment has been minimized.

Show comment
Hide comment
@kmlawson

kmlawson Dec 22, 2015

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment