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