Skip to content

Commit 21da0bb

Browse files
committed
Removed all empty lines
1 parent 6b3342e commit 21da0bb

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

Remove-Empty-Lines/remove-empty-lines.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
import sys
2-
3-
# Check if the correct number of arguments is provided
42
if len(sys.argv) != 3:
53
print("Usage: python remove_empty_lines.py input_file output_file")
64
sys.exit(1)
7-
85
input_file = sys.argv[1]
96
output_file = sys.argv[2]
10-
117
try:
12-
# Open the input file for reading and the output file for writing
138
with open(input_file, "r") as in_file, open(output_file, "w") as out_file:
149
for line in in_file:
15-
# Check if the line is not empty (contains at least one non-space character)
1610
if line.strip():
1711
out_file.write(line)
18-
1912
print(f"Empty lines removed and saved to {output_file}")
2013
except FileNotFoundError:
2114
print("File not found. Please check the file paths.")

0 commit comments

Comments
 (0)