Нет подходящей альтернативы для ввода - строка 25 Jython - PullRequest
0 голосов
/ 18 октября 2019

Я создаю ExecuteScript в NiFi, поэтому он читает строку и меняет ',' на '#'. Но я не очень хорошо разбираюсь в jython и редко использую процессор ExecuteScript.

class PyStreamCallback(StreamCallback):
    def __init__(self):
        pass

    def process(self, inputStream, outputStream):
        try:

            # Input Flowfile
            input = IOUtils.toString(inputStream, StandardCharsets.UTF_8)

            # Transform Content
            split_csv_line = input.split('"')
            isolate_description = split_csv_line[1]
            description = isolate_description.replace(",","#")
            new_list = split_csv_line[0] + description + split_csv_line[2]

            # Output Flowfile
            outputStream.write(StringUtil.toBytes(new_list))

flowFile = session.get()

if flowFile != None:
    flowFile = session.write(flowFile, TransformCallBack())
    # Transfer flowFile to output relationship
    session.transfer(flowFile, REL_SUCCESS)
...