Command Line Importing with Day One

Before I started using Day One to do my journaling, I made entries in a Microsoft Word document. Once I decided I was going to stay with the application, I wanted to import all my older entries so they would all be in one place. There is an automated import option, but it only supports MacJournal and Momento the last time I checked. I had to find another way. Cutting and pasting directly into the app a day at a time was out of the question as I had three and half years of daily entries. That’s when I looked into Day One command line option.

Day One provides a program that allows you to interface with the database via the OS X Terminal command line. It was a simple matter of downloading and installing it. Once installed, enter dayone --help to see the complete syntax. There appears to be only one command and that’s to add new entries. It does provide several ways to do that. I was interested in the one that allowed to an entry to a specific date:

echo "journal data" | ./dayone -d="01-24-2009" new

The “journal data” was the entry for the day and “01-24-2009” was day of the entry. I did one entry manually and it worked as advertized. Now to do over 1200 more.

I had formatted my Word entries as a month and day followed by a tab and then my journal data. This allowed me to select it all in Word and paste it into Excel as it recognizes the tab as a data separator. The date appeared in the first column and the text in the second. Excel recognized the date as such and added the current year to it to make it complete. Since my entries were all in past years, I had to change them. I did this by selecting all the dates for a given year and then selecting the Edit/Replace option. I entered 2014 as the data to be replaced with 2011 as the data to replace it with for my 2011 entries. I then repeated it for the rest of the years. I now had the two pieces of data for each new entry into Day One. The next step was getting it into the command.

There are all sorts of sophisticated ways to do this. Since it was a one off, I was happy with quick and dirty. I did this by inserting a new column into my Excel file and then entered this command into the first row:

= "echo " & CHAR(34) & C1 & CHAR(34) & " | ./dayone -d=" & CHAR(34) &TEXT(B1,"mm-dd-yyyy") & CHAR(34) & " new"

C1 is the cell containing the entry text and B1 is the cell containing the date. CHAR(34) is the character code for the double quote. Notice the “mm-dd-yyy” for the date. Day One says it’s flexible on the date format. To be safe, I used the US version since I’m running it there. Experiment with manual entries to see what works for you.

When I was satisfied that it worked for the first row, I dragged it down the column to apply it to all the other rows. I now had all the commands to import the entries. The next step was to process them.

My first attempt was a shell script. It would only work with a single entry. I don’t know if it was a problem with Day One or my lack of knowledge in using one. In the end, I just cut and pasted the commands in the spread sheet to the Terminal command line. When you do, all the commands will be processed except the last one. Be sure to press enter to process it. I started with just a few and verified they showed up in Day One in the right place. When they did, I cut and pasted larger chunks verifying them each time. Finally, I did them a year at a time. It may be possible to do them all at once, but I wasn’t sure if there was some sort of buffer limit for the clip board. I took the safe route.

This method is only useful if you can get your entries into Excel. It might also work using Apple’s Numbers application. All my entries were pretty short. Longer entries with paragraphs maybe a problem. Also any entry with double quotes in them would cause the echo command to terminate early. You might get around this by adding an escape character before them. I would recommend adding a single entry to Excel by hand to see if it works on your data. If your data is in an application not supported by the import option, check for an export option to tab separated values. Comma separated values is more conventional, but it’s most likely you will already have commas in your entries.

This solution may be of use to just a few journal writers that have converted to Day One. Hopefully others can use it as a starting point for their own solution.

Leave a Reply