Created
May 18, 2012 14:22
-
-
Save jshiell/2725521 to your computer and use it in GitHub Desktop.
Fix malformed FXG files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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