I'm fairly new with IIB, currently what I want to achieve is to delete a single line from a TXT if it contains a specific word for example the word USA as per below.I read it as a BLOB then convert it to a string. Should I achieve this using Compute node or Java node? Thanks in advance.
e.g
Before
Hello my name
is Malcom and I live
in the USA
After
Hello my name
is Malcom and I live
Current Flow FileInput -> Compute -> JavaCompute -> FileOutput
FileInput : To read data from a specific folder
Compute : Replace a string to another string (mask)
CREATE PROCEDURE getBLOBMessage() BEGIN
DECLARE fullBLOB CHARACTER;
SET fullBLOB = CAST(OutputRoot.BLOB.BLOB as char CCSID 1208 Encoding 815);
SET OutputLocalEnvironment.msg = fullBLOB;
END;
CREATE PROCEDURE maskMessage(INOUT msg CHARACTER) BEGIN
SET msg = REPLACE (msg, '431.111.55.113', 'XXX.XXX.XX.XXX');
SET msg = REPLACE (msg, '111.115.11.112', 'XXX.XXX.XX.XXX');
SET msg = REPLACE (msg, '111.112.11.112', 'XXX.XXX.XX.XXX');
SET msg = REPLACE (msg, '111.111.111.116', 'XXX.XXX.XXX.XXX');
SET msg = REPLACE (msg, '172.16.18.72', 'XXX.XX.XX.XX');
SET msg = REPLACE (msg, 'b1111111110', 'XXXXXXXXXXX');
SET msg = REPLACE (msg, '11111111101', 'XXXXXXXXXXX');
SET msg = REPLACE (msg, '11111111111', 'XXXXXXXXXXX');
SET msg = REPLACE (msg, 'B1111111111', 'XXXXXXXXXXX');
SET msg = REPLACE (msg, 'Q1111111', 'XXXXXXXX');
SET msg = REPLACE (msg, '11111111111N', 'XXXXXXXXXXXX');
SET OutputRoot.BLOB.BLOB = CAST (msg AS BLOB CCSID 1208 Encoding 815);
END;
JavaCompute: For removing line maybe?
FileOutput: To generate the output txt file
If you use the Record detection feature of the File Input node, your requirements can be fulfilled in ESQL.
FileInput node:
End of Data
toFinish File
of FileOutput nodeCompute node:
FileOutput node:
Example input:
Resulting output: