Skip to content

Instantly share code, notes, and snippets.

@rsinger
Created September 22, 2010 13:47
Show Gist options
  • Save rsinger/591698 to your computer and use it in GitHub Desktop.
Save rsinger/591698 to your computer and use it in GitHub Desktop.
require '/Users/rosssinger/Projects/ruby-marc/trunk/lib/marc'
tags = ['001','005', '100','110','111','240','243','245', /^6[0-9][0-9]$/, '700', '710', '711']
recs = 0
fields = 0
MARC::Reader.new('/Users/rosssinger/Downloads/ic_marc.mrc.mrc').each do | rec |
recs += 1
tags.each do |tag|
if tag.is_a?(String)
t = rec.find_all { | f | f.tag == tag }
else
t = rec.find_all { | f | f.tag =~ tag }
end
fields += t.length
end
end
puts "Records: #{recs}"
puts "Fields: #{fields}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment