Created
October 10, 2008 14:04
-
-
Save danielharan/16048 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def starts_with?(str) | |
self =~ /#{str}/ | |
end | |
end | |
names_to_edid = File.open(File.dirname(__FILE__) + '/edid_names').read.split("\n"). | |
collect {|line| edid, pruid, edname = line.split("|"); [edname.strip, edid.strip]}. | |
inject({}) {|hash,e| hash[e.first] = e.last; hash } | |
lines = File.open(ARGV[0]).read.split("\n").inject({}) {|hash,e| pc, rest = e.split(','); hash[pc] = rest; hash} | |
lines.reject! {|k,v| v.nil?} | |
lines.each do |k,v| | |
if v =~ /^[^a-z]*$/ | |
puts "#{k},#{v}" | |
else | |
begin | |
edid = names_to_edid.detect {|name,edid| name.starts_with?(v)}.last | |
puts k + "," + edid | |
rescue | |
puts "oops on [#{k},#{v}]" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment