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 24 lines (20 sloc) 0.558 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/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 -> 6 14
# 598.29729 -> 5 98
# 767 -> 7 67

file = ARGV[0]

File.read(file).each do |line|
  next unless line.length > 2
  line.chomp!
  hundreds = line.slice(0,1)
  tensandones = line.slice(1,2)
  next unless (/\d/).match(hundreds)
  next unless (/\d\d/).match(tensandones)
  puts "#{hundreds} #{tensandones}"
end
Something went wrong with that request. Please try again.