Welcome, guest | Sign In | My Account | Store | Cart

For those of you who have not found a Bible reading schedule or are not satisfied with what you have and want a change, the following recipe is provided as the result of a programming project today for the New Year. Begin with the first reference and read up to but not including the next reference. Continue from day to day, and you will find that by the end of the year, the entire Bible has been read with equally spaced portions of reading and time. The schedule was developed with the intention to read about the same number of words per day. The Bible used was "bible13.txt" (King James Version) from Project Gutenberg.

Python, 117 lines
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
OLD = ['Genesis', 'Exodus', 'Leviticus', 'Numbers', 'Deuteronomy', 'Joshua',
       'Judges', 'Ruth', '1 Samuel', '2 Samuel', '1 Kings', '2 Kings',
       '1 Chronicles', '2 Chronicles', 'Ezra', 'Nehemiah', 'Esther', 'Job',
       'Psalm', 'Proverbs', 'Ecclesiastes', 'Song of Solomon', 'Isaiah',
       'Jeremiah', 'Lamentations', 'Ezekiel', 'Daniel', 'Hosea', 'Joel',
       'Amos', 'Obadiah', 'Jonah', 'Micah', 'Nahum', 'Habakkuk', 'Zephaniah',
       'Haggai', 'Zechariah', 'Malachi']
NEW = ['Matthew', 'Mark', 'Luke', 'John', 'Acts', 'Romans', '1 Corinthians',
       '2 Corinthians', 'Galatians', 'Ephesians', 'Philippians', 'Colossians',
       '1 Thessalonians', '2 Thessalonians', '1 Timothy', '2 Timothy', 'Titus',
       'Philemon', 'Hebrews', 'James', '1 Peter', '2 Peter', '1 John', '2 John',
       '3 John', 'Jude', 'Revelation']
ALL = OLD + NEW

################################################################################

def main():
    bible_text = get_bible()
    bible_array = parse_bible(bible_text)
    iterator = Bible_Iter(bible_array)
    words = iterator.total / 365
    index = words
    try:
        while True:
            print(iterator.get_reference())
            temp = int(index)
            while temp != iterator.index:
                iterator.next_word()
            iterator.next_vers()
            index += words
    except:
        input('DONE')

def get_bible():
    return open('bible13.txt').read()

def parse_bible(string):
    'Parse Bible and return 3D array.'
    book = chap = vers = 1
    form = '%02u:%03u:%03u'
    book_s, chap_s, vers_s = [], [], []
    start = 0
    while True:
        try:
            start = string.index(form % (book, chap, vers), start) + 11
            end = string.index('\n\n', start)
            vers_s.append(' '.join(string[start:end].split()))
            start = end
            vers += 1
        except:
            if vers != 1:
                chap_s.append(vers_s)
                vers_s = []
                chap += 1
                vers = 1
            elif chap != 1:
                book_s.append(chap_s)
                chap_s = []
                book += 1
                chap = 1
            elif book != 1:
                return book_s
            else:
                raise EOFError

################################################################################

class Bible_Iter:

    def __init__(self, bible_3D):
        self.bible = bible_3D
        self.total = 0
        self.__book = 0
        self.__chap = 0
        self.__vers = 0
        self.__word = 0
        self.index = 0
        for book in bible_3D:
            for chapter in book:
                for index, verse in enumerate(chapter):
                    words = verse.split()
                    chapter[index] = words
                    self.total += len(words)

    def get_word(self):
        return self.bible[self.__book][self.__chap][self.__vers][self.__word]

    def next_word(self):
        self.index += 1
        self.__word += 1
        if len(self.bible[self.__book][self.__chap][self.__vers]) == self.__word:
            self.__word = 0
            self.__vers += 1
            if len(self.bible[self.__book][self.__chap]) == self.__vers:
                self.__vers = 0
                self.__chap += 1
                if len(self.bible[self.__book]) == self.__chap:
                    self.__chap = 0
                    self.__book += 1
                    if len(self.bible) == self.__book:
                        self.__book = 0
                        raise EOFError

    def next_vers(self):
        vers = self.__vers
        while vers == self.__vers:
            self.next_word()

    def get_reference(self):
        book = ALL[self.__book]
        reference = '{0} {1}:{2}'.format(book, self.__chap + 1, self.__vers + 1)
        return reference

################################################################################
    
if __name__ == '__main__':
    main()

For those interested in developing their own Bible reading guides, the code is presented here for further development and modification.

3 comments

Stephen Chappell (author) 15 years, 2 months ago  # | flag

Does anyone know of Python code that can divide words up by syllable? If it takes a quantum of time to read each syllable and space, then the words of the Bible (or any book for that matter) could be divided up that way. Once the total count was known, the book could be split up by a similar algorithm, and the time to read each section would be even more likely to take the same amount of time.

David Lambert 15 years, 2 months ago  # | flag

I expect a code like this to maintain an interactive database and current time. Thus when, during my meditations I accidentally read a double helping the program knows to reduce my load during the remaining two hundred twenty-seven days.

David Lambert 15 years, 2 months ago  # | flag

(you could process the bible13 with TeX set to narrow width. Then parse the log file for syllabic split. You'd do this all from within python using subprocess module)

Created by Stephen Chappell on Thu, 1 Jan 2009 (MIT)
Python recipes (4591)
Stephen Chappell's recipes (233)

Required Modules

  • (none specified)

Other Information and Tasks