Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 26 lines (22 sloc) 0.605 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#!/usr/bin/ruby

# Given a file of Dewey call numbers,
# output a file ready to be used
# to make a hundreds-by-tens-and-ones levelplot
# dentogram, by printing the hundreds and
# tens-and-ones numbers separated by a space
#
# 614.59939 -> 61 45
# 598.29729 -> 59 82
# 767 -> 76 70

file = ARGV[0]

File.read(file).each do |line|
  next unless line.length > 2
  line.chomp!
  line.gsub!(/\./, '')
  line = line + "0" if line.length < 4
  first = line.slice(0,2)
  second = line.slice(2,2)
  next unless /[0-9]{2}/.match(first)
  next unless /[0-9]{2}/.match(second)
  puts "#{first} #{second}"
end
Something went wrong with that request. Please try again.