Ruby-marc

Revision as of 03:05, 21 March 2009 by Bess (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Revision as of 03:05, 21 March 2009 by Bess (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Rdocs are here: http://marc.rubyforge.org

These are some recipes for useful things you might want to do with ruby-marc. If you need a file of MARC records to work with, you can download one from here: http://www.archive.org/search.php?query=mediatype%3A%22data%22%20MARC.


Recipe: read in a large file of marc records, pull out one of them and write it to a separate file

require 'rubygems'
require 'marc'

reader = MARC::Reader.new('/usr/local/projects/bl-demo/data/lc_records.utf8.mrc')
record = reader.first
writer = MARC::Writer.new('/tmp/file2')
writer.write(record)
writer.close