Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to sort through a bible.txt by entering the name, verse etc.?
    primarykey
    data
    text
    <p>Here are my criteria:</p> <ol> <li><p>Get a copy of the text of the whole bible </p></li> <li><p>This should be ready to open, read, split up into fields </p></li> <li><p>Use this to create a persistent dictionary variable called bible</p></li> <li><p>Set up your python program so when you type as I have shown, the program will know what you entered on the command line. Do NOT have it prompt you for the words. </p></li> <li><p>Parse that reference meaning get the book, the chapter, the start verse and end verse. Other variations are rev 1:1, rev 12, or rev 10:1-3</p></li> <li><p>When it prints have the output limit to a width of 100 characters wide before wrapping to a new line, which should then be indent enough to have the reference shown on the left and some spaces and the text aligned on the right.</p></li> </ol> <p>The text in the text file looks like this:</p> <pre><code>0 | gen 1:1 | In the beginning God created the heaven and the earth. 1 | gen 1:2 | And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters. 2 | gen 1:3 | And God said, Let there be light: and there was light. </code></pre> <p>My code so far looks like this:</p> <pre><code>import os import sys import re word_search = raw_input(r'Enter a word to search: ') book = open("kjv.txt", "r") first_lines = {36: 'Genesis', 4812: 'Exodus', 8867: 'Leviticus', 11749: 'Numbers', 15718: 'Deuteronomy', 18909: 'Joshua', 21070: 'Judges', 23340: 'Ruth', 23651: 'I Samuel', 26641: 'II Samuel', 29094: 'I Kings', 31990: 'II Kings', 34706: 'I Chronicles', 37378: 'II Chronicles', 40502: 'Ezra', 41418: 'Nehemiah', 42710: 'Esther', 43352: 'Job', 45937: 'Psalms', 53537: 'Proverbs', 56015: 'Ecclesiastes', 56711: 'The Song of Solomon', 57076: 'Isaih', 61550: 'Jeremiah', 66480: 'Lamentations', 66961: 'Ezekiel', 71548: 'Daniel' } for ln, line in enumerate(book): if word_search in line: first_line = max(l for l in first_lines if l &lt; ln) bibook = first_lines[first_line] template = "\nLine: {0}\nString: {1}\nBook:\n" output = template.format(ln, line, bibook) print output </code></pre> <p>I know that It is pretty messed up, so please help to straighten me out.</p> <p><strong>A summary of what I think I am doing:</strong></p> <p>Create a dictionary from the text file, then somehow get the user to input a chapter and verse, and then have the program be able to spit those chapter and verses out.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload