Created
          July 8, 2016 14:42 
        
      - 
      
 - 
        
Save rahearn/08378a974c9b78afd21f216a563a763f to your computer and use it in GitHub Desktop.  
    translate pipe-delimited files to CSV
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | require 'csv' | |
| path = ARGV[0] | |
| fail "path required" if path.nil? | |
| csv = CSV.open "#{path}.csv", "w" | |
| begin | |
| File.open(path).each do |line| | |
| line = line.strip.force_encoding('iso-8859-1').encode 'UTF-8' | |
| csv << line.split('|', -1) | |
| end | |
| ensure | |
| csv.close | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment