Skip to content

Instantly share code, notes, and snippets.

@tkieft
Created October 24, 2016 01:15
Show Gist options
  • Save tkieft/51618be7f8dad3fd0505c668c057955d to your computer and use it in GitHub Desktop.
Save tkieft/51618be7f8dad3fd0505c668c057955d to your computer and use it in GitHub Desktop.
Journler -> DayOne
#! /usr/bin/env python
# Import Journler entries into DayOne 2.0
# Keeps Date and Title, does not attempt to import Category or Tags
import os
import dateutil.parser
# The folder containing your Journler export
#
# In Journler: File -> Export Journal
# Data Format: Plain Text
# ✓ Include Header
# ✓ Save Each Entry in its own file all in a single folder
DIR = "/Users/tkieft/Desktop/Journler/"
# The Location of your DayOne 2.0 Journal
JOURNAL = "/Users/tkieft/Library/Group Containers/5U8NS4GX82.dayoneapp2/Data/Auto Import/Default Journal.dayone"
# The DayOne CLI: http://help.dayoneapp.com/day-one-tools/
DAYONE = "/usr/local/bin/dayone"
def extract(string):
return string.replace('\x00','').split(": ")[1].strip()
files = [DIR + file for file in os.listdir(DIR) if not file.startswith(".")]
for file in files:
f = open(file, 'r')
title = extract(f.readline())
date = dateutil.parser.parse(extract(f.readline()))
category = extract(f.readline())
tags = extract(f.readline()).split()
f.readline()
content = f.read().replace('\x00','')
f.close()
cmd = DAYONE + " -j=\"" + JOURNAL + "\" -d=\"" + date.strftime("%c") + "\" new"
pipe = os.popen(cmd, 'w')
pipe.write("# " + title + "\n\n")
pipe.write(content)
retval = pipe.close()
print retval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment