Over the past few months I've been exploring python, and given my
background with the perl module MARC::Record I set about writing pymarc
which (I hope) extracts the essence of MARC::Record but provides a
pythonic interface.
The module works (ahem), and has a test suite, but I'm looking for feedback,
so here's the URL:
http://www.python.org/pypi?:action=display&name=pymarc
Here's a couple of examples from the docs:
1. Reading a batch of records and printing out the 245 subfield a:
from pymarc import MARCReader
reader = MARCReader( 'test/marc.dat' )
for record in reader:
print record['245']['a']
2. Print multiple fields from a record:
print record.fields( '600', '610', '650' )
3. Creating a record and writing it out to a file:
from pymarc import Record, Field
record = Record()
record.addField( \
Field( \
tag = '245',
indicators = ['0','1'],
subfields = [ \
'a', 'The pragmatic programmer : ',
'b', 'from journeyman to master /',
'c', 'Andrew Hunt, David Thomas.' ] ) )
out = file( 'file.dat', 'w' )
out.write( record.asMARC21() )
There's a TODO list of things I'd like the module to do eventually. If
anyone is interested in helping develop the library please let me know
and I'll get you cvs (soon to be svn) access.
Many thanks to Dan Chudnov for the python tips, advice and guidance which
helped me get this far.
//Ed
|