Skip to content

Instantly share code, notes, and snippets.

@joeeeeey
Last active January 12, 2018 08:26
Show Gist options
  • Save joeeeeey/10be1ed8922b9b5f55b322a2df95892c to your computer and use it in GitHub Desktop.
Save joeeeeey/10be1ed8922b9b5f55b322a2df95892c to your computer and use it in GitHub Desktop.
Ruby read big file, filter and delete line.
output_file_path = "output_file_path"
input_file_path = "input_file_path"
open(input_file_path, 'r') do |f|
open(output_file_path, 'w') do |f2|
f.each_line do |line|
if line != "\n" # logic here
f2.write(line)
end
end
end
end
# If need to replace old file bu new file
FileUtils.mv output_file_path, input_file_path
@joeeeeey
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment