Member since
12-03-2017
149
Posts
26
Kudos Received
11
Solutions
My Accepted Solutions
Title | Views | Posted |
---|---|---|
1380 | 11-03-2023 12:17 AM | |
3086 | 12-12-2022 09:16 PM | |
1171 | 07-14-2022 03:25 AM | |
1854 | 07-28-2021 04:42 AM | |
2177 | 06-23-2020 10:08 PM |
05-29-2020
01:03 AM
Hi, This is one option using simple Python script - (I am not python expert, there should be better way to write below code, but this works) Just use ExecuteScript processor and add below code as script body - import csv
import java.io
from org.apache.commons.io import IOUtils
from java.nio.charset import StandardCharsets
from org.apache.nifi.processor.io import StreamCallback
global filename
class PyStreamCallback(StreamCallback):
def __init__(self):
pass
def process(self, inputStream, outputStream):
text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
lines = text.splitlines()
reader = csv.reader(lines)
headerList = list(next(reader))
dataList = list(next(reader))
global filename
filename = dataList[headerList.index('Name')] + "_" + dataList[headerList.index('Country')] + ".csv"
outputStream.write(bytearray(text.encode('utf-8')))
flowFile = session.get()
if (flowFile != None):
flowFile = session.write(flowFile, PyStreamCallback())
flowFile = session.putAttribute(flowFile, "filename", filename)
session.transfer(flowFile, REL_SUCCESS) Thanks Mahendra
... View more
05-29-2020
12:54 AM
Hey, This is the one option using Python script - Just use ExecuteScript processor and use below script as script body - (I am not Python expert, there should be better way to write below code, but this works) import csv
import java.io
from org.apache.commons.io import IOUtils
from java.nio.charset import StandardCharsets
from org.apache.nifi.processor.io import StreamCallback
global filename
class PyStreamCallback(StreamCallback):
def __init__(self):
pass
def process(self, inputStream, outputStream):
text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
lines = text.splitlines()
reader = csv.reader(lines)
headerList = list(next(reader))
dataList = list(next(reader))
global filename
filename = dataList[headerList.index('Name')] + "_" + dataList[headerList.index('Country')] + ".csv"
outputStream.write(bytearray(text.encode('utf-8')))
flowFile = session.get()
if (flowFile != None):
flowFile = session.write(flowFile, PyStreamCallback())
flowFile = session.putAttribute(flowFile, "filename", filename)
session.transfer(flowFile, REL_SUCCESS) Thanks Mahendra
... View more
05-24-2020
07:36 AM
I could not succeed in multipart upload with InvokeHTTP processor. So I used a simple java code to upload file using 'multipart/form-data'. Invoked java code from nifi SprintContextProcessor. As my file was large, I wrote the file content to disc before invoking 'SprintContextProcessor' and using java code read the file content and uploaded to the target. You can transfer flow file content directly to the java code (SpringContext processor). Thanks Mahendra
... View more
12-01-2019
09:47 PM
Hi @ankita_pise , Were you able to achieve this using InvokeHttp processor ? I am also looking for the solution. Thanks, Mahendra
... View more
04-03-2019
04:54 AM
1 Kudo
Hello, I am observing quite strange behaviour of anyDelineatedValue expression when I use it with 'OR' operation. If I use 'AND' operation there is no issues. Input attribute value: org.entitlement.list=AA,CC,DD,FF Expression used in RouteOnAttribte/UpdateAttribute processor : ${anyDelineatedValue("${org.entitlement.list}", ","):equals('BB'):or(${anyDelineatedValue("${org.entitlement.list}", ","):contains('EE')})} Above expression is giving ArrayIndexOutOfBoundException for OR operation for the given input (where both the values which expression is looking is not present) If I use 'AND' operation expression works fine. What is the difference here? If I pass BB or EE in the input then expression wont give exception ! Looks like defect, can some one please suggest if anything wrong in this? Thanks Mahendra
... View more
Labels:
- Labels:
-
Apache NiFi
12-05-2018
11:34 AM
Thank you, its working with ${anyDelineatedValue("${your_attribute}", ","):equals("US")}
... View more
12-05-2018
10:24 AM
Hello, I have a scenario where I need to check for string contains, but for exact match of comma separated words. Example String: example = "US,UK,IN,NOT_APPLICABLE" I want to check above string contains specific word like 'US' or 'LE' Case 1: example.contains('US') . - expecting TRUE Case 2: example.contains('LE') - expecting FALSE If I use normal :contains(), case 2 will also return TRUE since 'LE' is part of 'NOT_APPLICABLE' But I want to check contains for comma separated values strictly. Is there any easy way to achieve this? Thanks, Mahendra
... View more
Labels:
- Labels:
-
Apache NiFi
11-23-2018
05:54 AM
Thanks @Shu ! It worked, I was using 'Return type' as auto instead of json in EvaluateJsonPath. Thanks for the reply 🙂
... View more
11-22-2018
10:53 AM
Hello, I have below json as flowfile content - { "organization_id": "life-360", "message_type_id": "MSG01", "consent_required": "1", "country_list": [
"GB",
"IT",
"BG"
]
} I want below content as output - GB, IT, BG I am able to get "country_list": [ "GB", "IT", "BG" ] in flow file using JOLT but not comma separated country list. Could any one please help with best way? Thanks, Mahendra
... View more
Labels:
- Labels:
-
Apache NiFi
11-20-2018
07:29 AM
Hello , I have a scenario where I need to run a processor on NiFi restart. Is there any way to trigger a nifi processor whenever nifi restarts ? Thanks in advance, Mahendra
... View more
Labels:
- Labels:
-
Apache NiFi