[Solved] Ruby CSV.readline convert to hash


matches = []

File.readlines('data.txt').each do |line|

  my_line = line.chomp.split(', ').map! { |l| l.split(/\s+(?=\d+$)/) }.flatten 

  matches << [['player1', 'scope_p1', 'player2', 'score_p2'], my_line].transpose.to_h

end

p matches

Example Here

3

solved Ruby CSV.readline convert to hash