nathan11g/dayone_export — pull request #15 by quentinsf (2013-03-04 18:40:49+00:00)
Title: Multiple-file output

Hi Nathan -

I've made a small change to your excellent dayone_export for my own particular needs. Feel free to pull it if you think it might be useful for others, or reject it if not - I won't be offended!

I wanted to be able to create multiple output files split up by date rather than just a single monolithic one; in my case, I'll probably have them named something like journal_2013_03.md.

So this patch adds the --time-group parameter which takes a strftime-style string to format the timestamp, and creates a new output file with this as a suffix whenever the result changes.

e.g.

`dayone_export --output journal --time-group "_%Y_%m.md" --format md Journal.dayone`

I've changed the dayone_export() function so that, rather than just returning the text, it returns a generator giving (suffix, text) each time the suffix changes. That's perhaps a slightly eccentric way of doing it but it seems to work OK, and I couldn't think of an alternative involving so few line changes from your original!

If you like this approach and want to include it I can update the docs too, if that would be helpful.

All the best, and many thanks,
Quentin