Skip to content

Instantly share code, notes, and snippets.

@callumj
Created June 6, 2011 09:21
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 callumj/1009981 to your computer and use it in GitHub Desktop.
Save callumj/1009981 to your computer and use it in GitHub Desktop.
Reorder Weka parsed CSV files
file_p = File.open(ARGV[0])
lines = file_p.readlines
file_p.close
lines.each do |line|
match_data = line.strip.match(/".+(n[0-9]+)_(.+)[.]log",(.+)/)
if match_data != nil
puts "#{match_data[2]}_#{match_data[1]},#{match_data[3]}"
else
puts line
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment