Created
November 9, 2021 07:44
-
-
Save Rahulsharma0810/489a8cdd0c8b896c680bf63c1f8c4464 to your computer and use it in GitHub Desktop.
Script to remove blank lines from files in a directory
This file contains 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
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