Skip to content

Commit

Permalink
NiFi scripts: added multiple output(s) for cerner decompression.
Browse files Browse the repository at this point in the history
  • Loading branch information
vladd-bit committed Mar 8, 2024
1 parent cbe733a commit 12bea44
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion nifi/user-scripts/parse-cerner-blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
# expected (optional)
OUTPUT_CHARSET = "windows-1252"

# possible values:
# - binary: output binary code
# - string: output string after decompression
OUTPUT_MODE = "binary"

input_cerner_blob = str(sys.stdin.buffer.read(), INPUT_CHARSET).encode(INPUT_CHARSET)

for arg in sys.argv:
Expand All @@ -20,8 +25,13 @@
INPUT_CHARSET = str(_arg[1]).lower()
elif _arg[0] == "output_charset":
OUTPUT_CHARSET = str(_arg[1]).lower()
elif _arg[0] == "output_mode":
OUTPUT_MODE = str(_arg[1]).lower()

decompress_blob = DecompressLzwCernerBlob()
decompress_blob.decompress(input_cerner_blob)

sys.stdout.write(decompress_blob.output_stream.decode(encoding=OUTPUT_CHARSET))
if OUTPUT_MODE == "binary":
sys.stdout.buffer.write(bytes(decompress_blob.output_stream))
else:
sys.stdout.write(decompress_blob.output_stream.decode(OUTPUT_CHARSET))

0 comments on commit 12bea44

Please sign in to comment.