text = <<~DOC ID Name Type Size Date 735557379 Mitch Murder - Kung Fury (Lost Tapes) - 2015 FOLDER 38.37 MB 8 months ago 589243897 A Game Of Thrones ~ Books 1-5 EPUB,MOBI & PDF [GrYff0N] FOLDER 83.36 MB 2 years ago 735557525 VA - Kung Fury (2015) FOLDER 109.84 MB 8 months ago 819683233 19000 FOLDER 1.77 GB 2 days ago 819682329 18000 FOLDER 3.12 GB 2 days ago 819681592 17000 FOLDER 4.23 GB 2 days ago 784060241 Doctor.Who.2005.S12.1080p.BluRay.x264-SHORTBREHD FOLDER 31.73 GB 2 months ago 601795129 chill.institute FOLDER 51.66 GB 2 days ago DOC def parse_fields(str:, hash_result: false, row_sep: "\n") rows = str.split(row_sep) header = rows.shift.scan(/\w+\s+/) col_widths = header.map(&:length) header.map!(&:strip) acc_index_memo = {} rows.map! do |r| result = [] col_widths.each_with_index { |w, i| start_index = i > 0 ? acc_index_memo[i] ||= col_widths.slice(0, i).inject(:+) : 0 result << r[start_index, w].strip } result end hash_result ? rows.map {|r| Hash[header.zip(r)] } : rows end parse_fields(str: text) parse_fields(str: text, hash_result: true) parse_fields(str: text, hash_result: true, row_sep: /\R/)