Skip to content

Instantly share code, notes, and snippets.

@phroa

phroa/merge_speedscout_17.rb Secret

Last active Mar 30, 2017
Embed
What would you like to do?
#!/usr/bin/env ruby
require 'csv'
lines = ARGF.each_line.map(&:chomp)
# This may have to be 15 on windows computers for unknown reasons; line endings?
slices = lines.each_slice(14).map do |slice|
slice.map do |l|
l.split ','
end
end
data = CSV.generate do |csv|
csv << ['Team', 'Match', 'Alliance', 'Auto Baseline', 'Auto Low', 'Auto High', 'Auto Gear', 'Teleop Low', 'Teleop High', 'Gears', 'Climbed', 'Comments']
slices.each do |slice|
a = [slice[0][1].strip,
slice[2][1].strip,
slice[1][1].strip,
slice[4][1].strip,
slice[5][1].strip,
slice[6][1].strip,
slice[7][1].strip,
slice[9][1].strip,
slice[10][1].strip,
slice[11][1].strip,
slice[12][1].strip]
a << slice[14][1].strip if slice[14][1]
csv << a
end
end
puts data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.