spark: line counter artifact with verification

This commit is contained in:
spark committed 2026-10-30 08:12:51 +00:00
1 parent d3a3188c9c
commit 43d1acf4c0
2 files changed
+22

No files matched your search

+1
View File
@@ -0,0 +1 @@
18
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
"""Line counter utility - counts non-empty lines in a file."""
import sys
def count_nonempty_lines(filepath):
"""Count lines that have content (not just whitespace)."""
count = 0
with open(filepath, 'r') as f:
for line in f:
if line.strip():
count += 1
return count
if __name__ == '__main__':
if len(sys.argv) != 2:
print("Usage: python line_counter_artifact.py <file>")
sys.exit(1)
filepath = sys.argv[1]
result = count_nonempty_lines(filepath)
print(result)