Created
March 31, 2011 16:40
-
-
Save ebot/896728 to your computer and use it in GitHub Desktop.
Strips out doc id brackets at trims white space on csv files
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
| #!/usr/bin/env ruby -wKU | |
| input = File.new 'generic_doc_labels.csv' | |
| output = File.new 'generic_document_labels.csv', 'w' | |
| line_number = 0 | |
| input.each_line do |line| | |
| unless line_number == 0 | |
| fields = line.split '","' | |
| fields[0] = fields[0].gsub( /\{|\}/, '' ) | |
| line = '' | |
| fields.each { |field| line << "#{field.gsub("\"\n", '').chomp.strip}\",\"" } | |
| end | |
| output << line[0, line.length - 2] << "\n" | |
| line_number += 1 | |
| end | |
| input.close | |
| output.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment