Skip to content

Instantly share code, notes, and snippets.

@jshiell
Created May 18, 2012 14:22
Show Gist options
  • Save jshiell/2725521 to your computer and use it in GitHub Desktop.
Save jshiell/2725521 to your computer and use it in GitHub Desktop.
Fix malformed FXG files
#!/usr/bin/ruby
if ARGV.length == 0
puts "Usage: #{__FILE__} <name of FXG to de-fubar>"
exit 1
end
filename = ARGV[0]
out = File.open("#{filename}.fixed", 'w')
File.open(filename, 'r') do |file|
last_line = nil
file.each_line do |line|
if line.strip =~ /^</
out << "#{last_line}\n" if !last_line.nil?
last_line = line.chomp
else
last_line += line.chomp
end
end
out << "#{last_line}\n" if !last_line.nil?
end
out.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment