Difference between revisions of "Ruby-marc"

From Code4Lib
Jump to: navigation, search
(New page: Rdocs are here: [http://marc.rubyforge.org http://marc.rubyforge.org] It can be useful to play around with a library in irb before you try to write a real app with it. Here are some irb e...)
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
Rdocs are here: [http://marc.rubyforge.org http://marc.rubyforge.org]
 
Rdocs are here: [http://marc.rubyforge.org http://marc.rubyforge.org]
  
It can be useful to play around with a library in irb before you try to write a real app with it. Here are some irb examples. 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 http://www.archive.org/search.php?query=mediatype%3A%22data%22%20MARC].
+
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 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 ====
 +
<pre>
 +
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
 +
</pre>

Latest revision as of 03:05, 21 March 2009

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