From 43d1acf4c0edb8cb50b9f5a8e016dc95fef595d7 Mon Sep 17 00:00:00 2001 From: spark Date: Fri, 30 Oct 2026 08:12:51 +0000 Subject: [PATCH] spark: line counter artifact with verification --- wizard-work/spark/line_count_result.txt | 1 + wizard-work/spark/line_counter_artifact.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 wizard-work/spark/line_count_result.txt create mode 100644 wizard-work/spark/line_counter_artifact.py diff --git a/wizard-work/spark/line_count_result.txt b/wizard-work/spark/line_count_result.txt new file mode 100644 index 0000000..25bf17f --- /dev/null +++ b/wizard-work/spark/line_count_result.txt @@ -0,0 +1 @@ +18 \ No newline at end of file diff --git a/wizard-work/spark/line_counter_artifact.py b/wizard-work/spark/line_counter_artifact.py new file mode 100644 index 0000000..8ec365d --- /dev/null +++ b/wizard-work/spark/line_counter_artifact.py @@ -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 ") + sys.exit(1) + + filepath = sys.argv[1] + result = count_nonempty_lines(filepath) + print(result) \ No newline at end of file