Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Rahulsharma0810/489a8cdd0c8b896c680bf63c1f8c4464 to your computer and use it in GitHub Desktop.
Save Rahulsharma0810/489a8cdd0c8b896c680bf63c1f8c4464 to your computer and use it in GitHub Desktop.
Script to remove blank lines from files in a directory
import os
files = os.listdir(os.curdir)
OUTPUT = ""
for file in files:
with open(file, encoding='utf-8') as f:
for line in f:
if not line.isspace():
OUTPUT += line
f = open(file, "w", encoding='utf-8')
f.write(OUTPUT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment