UPDATE: Generating Cutter numbers

Gerard Flanagan grflanagan at yahoo.co.uk
Tue May 23 16:12:20 EDT 2006


Gerard Flanagan wrote:
> All
>
> would anyone happen to have code to generate Cutter Numbers:
>
>   eg. http://www1.kfupm.edu.sa/library/cod-web/Cutter-numbers.htm
>
> or is anyone looking for something to do?-)  (I'm under pressure!)
>
> def cutter(lname, fname, book_title):
>
> (maybe more to it than that).
>
>
> cheers
>
> Gerard

Just for the archives - used a Cutter-Sanborn table obtained by
html-scraping (BeautifulSoup).  The final Cutter will depend on the
Cutters of existing books on the same shelf.

-------------------------------------------------------------------------------------------
from urllib import urlopen
from BeautifulSoup import BeautifulSoup as Soup

baseurl = 'http://www.librarian.or.kr/reference/mark/cutter%s.htm'

out = open('cutter2.txt','w')

try:
    for i in range(1,10):
        html = urlopen(baseurl % i).read()
        soup = Soup(html)
        for pre in soup('pre'):
            for line in pre.string.split('\n'):
                out.write(line.strip().replace('     ', ' ') + '\n')
finally:
    out.close()
-------------------------------------------------------------------------------------------

111 Aa
112 Aal
113 Aar
114 Aars
115 Aas
116 Aba
117 Abal
118 Abar
119 Abat
121 Abau
122 Abb
123 Abbat
124 Abbe
125 Abbo

...

86 Zol
87 Zon
88 Zop
89 Zot
91 Zou
92 Zs
93 Zu
94 Zuc
95 Zun
96 Zur
97 Zw
98 Zwi
99 Zy




More information about the Python-list mailing list