Skip to content

Instantly share code, notes, and snippets.

@jeffreybaird
Created August 17, 2012 15:24
Show Gist options
  • Select an option

  • Save jeffreybaird/3379856 to your computer and use it in GitHub Desktop.

Select an option

Save jeffreybaird/3379856 to your computer and use it in GitHub Desktop.
Script to cleanup the cap production marketing:sources output
#create a file (here called "file.txt") to paste the cap output into, run this file to clean the output.
require 'fileutils'
require 'tempfile'
t_file = Tempfile.new('sources.txt')
File.open("file.txt", 'r+') do |f|
f.each_line do |line|
line = line.to_s
line = line.strip
line = line.gsub(line.slice(0..30),"")
t_file.puts line if line.length > 2
end
end
FileUtils.mv(t_file.path, "sources.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment