Rotolux

Physics, Python programming, Miscellaneous geekness

Gutenberg rejoiner

So, what does one do with an e-reader? Why, read project Gutenberg etexts of course. One way to do this if you've got an eSlick is to use feedbooks to generate a nice pdf for you. In your profile settings, feedbooks lets you set up a custom pdf page format. I use 92 x 122mm, 11px Palatino for the eSlick. However, for novels it's probably better to just use a text file. Then the eSlick can reflow the text for you. The trouble is that Gutenberg etexts are filled with unwanted newline characters so they don't flow nicely on screen. What to do? Well, if you use Perl, you could try the script here. Alternatively, if you're a more enlightened Pythonista like me, you could use the following Python script to rejoin the lines (Note: I created this listing using this cool page):

from Tkinter import Tk
from tkCommonDialog import Dialog

class OpenFile(Dialog):
command = "tk_getOpenFile"

rootwin = Tk(); rootwin.withdraw()
fname = OpenFile().show().split('/')[-1]
if fname != '':
print >>open('out_'+fname, 'w'), open(fname).read().replace('\n\n','#uNiQuE#').replace('\n',' ').replace('#uNiQuE#','\n')

0 comments: