Skip to content

Instantly share code, notes, and snippets.

@phroa
Last active March 30, 2017 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phroa/dcf7ec5e5007bd7d715542167f1e04fc to your computer and use it in GitHub Desktop.
Save phroa/dcf7ec5e5007bd7d715542167f1e04fc to your computer and use it in GitHub Desktop.
#!/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