-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CU: 8693yammy | NiFi scripts: added parser script for cerner blobs.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import sys | ||
from .utils.cerner_blob import DecompressLzwCernerBlob | ||
|
||
# This needs to be investigated, records might have different charsets, | ||
# currently only tested with "iso-8859-1" | ||
# other frequently used encodings: "utf-16le", "utf-16be" | ||
# In some cases you will need to figure this out yourself, depending on | ||
# the data source | ||
INPUT_CHARSET = "iso-8859-1" | ||
|
||
# expected (optional) | ||
OUTPUT_CHARSET = "windows-1252" | ||
|
||
input_cerner_blob = bytearray(sys.stdin.read(), encoding=INPUT_CHARSET) | ||
|
||
for arg in sys.argv: | ||
_arg = arg.split("=", 1) | ||
|
||
if _arg[0] == "input_charset": | ||
INPUT_CHARSET = str(_arg[1]).lower() | ||
elif _arg[0] == "output_charset": | ||
OUTPUT_CHARSET = str(_arg[1]).lower() | ||
|
||
decompress_blob = DecompressLzwCernerBlob() | ||
decompress_blob.decompress(input_cerner_blob) | ||
|
||
sys.stdout.write(decompress_blob.output_stream.decode(encoding=OUTPUT_CHARSET)) |