Skip to content

Instantly share code, notes, and snippets.

@yagays
Created August 19, 2010 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yagays/537520 to your computer and use it in GitHub Desktop.
Save yagays/537520 to your computer and use it in GitHub Desktop.
タブ区切りテキストをmarshal_dump, marshal_loadするスクリプト
#/usr/bin/env ruby
def open_t_delimited_file(filename)
h = {}
File.open(filename).readlines.each do |line|
a = line.split("\t")
h[a[0]] = a
end
puts filename.to_s + " was loaded."
return h
end
if __FILE__ == $PROGRAM_NAME
b = open_t_delimited_file(ARGV[0])
f = open("b_hash.dump","wb")
Marshal.dump(b,f)
f.close
end
#/usr/bin/env ruby
f = open("b_hash.dump","rb")
str = Marshal.load(f)
f.close
puts str["NM_001081381"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment