Skip to content

Instantly share code, notes, and snippets.

@derde
Created February 13, 2021 22:57
Show Gist options
  • Save derde/334bfe5cdade48c9d05e39933c72280c to your computer and use it in GitHub Desktop.
Save derde/334bfe5cdade48c9d05e39933c72280c to your computer and use it in GitHub Desktop.
Rearrange the books of the Bible in the jumble that the Quaran follows
#! /usr/bin/python
"""Jumble the Bible according to Quran ordering ideas: shortest to longest"""
import urllib2,os
def QuranCmp(b,a):
return cmp(len(a[1]),len(b[1]))
kjvpcefile='kj.txt'
url='http://www.bibleprotector.com/TEXT-PCE-127.txt'
chapters=[]
currentchapter=''
if not os.path.exists(kjvpcefile) or os.path.getsize(kjvpcefile)==0:
open(kjvpcefile,'w').write(urllib2.urlopen(url).read())
for verse in open(kjvpcefile,'r'):
chapter,text=verse.split(':',1)
if chapter!=currentchapter:
currentchapter=chapter
verses=[]
chapters.append( (chapter,verses) )
verses.append(text)
chapters.sort(QuranCmp)
fd=open('Qjumble.txt','w')
fd.write("The Bible\nBy chapters\nArranged from longest\nTo shortest\n\n")
n=0
for chapter,verses in chapters:
n+=1
fd.write('%d. %s\n\n' % (n,chapter))
fd.writelines(verses)
fd.write('\n')
fd.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment