Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'yaml'
- lines = []
- temp = []
- tsv_file = File.open(ARGV[0], 'r')
- tsv_file.each_line { |line| lines << line }
- tsv_file.close
- keys = lines[0].split("\t")
- keys.map!(&:chomp)
- lines.shift
- lines.each do |line|
- values = line.split("\t")
- students = {}
- keys.each_index { |index| students[keys[index]] = values[index].chomp }
- temp.push(students)
- end
- if ARGV[1].nil?
- puts temp.to_yaml
- else
- File.open(ARGV[1], 'w') do |file|
- file.puts temp.to_yaml
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement