Skip to content

Instantly share code, notes, and snippets.

@jballanc
Created July 19, 2010 21:39
Show Gist options
  • Save jballanc/482067 to your computer and use it in GitHub Desktop.
Save jballanc/482067 to your computer and use it in GitHub Desktop.
Dir['*'].inject({}) {|h, f| k = f.gsub(/\d*\.tab$/, ''); h[k] ||= []; h[k] << f; h}.each {|k, v| File.open("#{k}.csv", 'w') {|o| v.each {|i| File.open(i, 'r') {|f| f.each_line {|l| l.gsub!(/[ |\t]+/, ','); o << l unless l[/\d+,\d+,(\d+),/,1] == '0' } } } } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment