nifi-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Payne <marka...@hotmail.com>
Subject Re: Put Database record
Date Wed, 20 Dec 2017 20:05:08 GMT
Aruna,

You'll only be able to update a given value once. So you could string together two UpdateRecord
processors
in a row, or in this specific case you could instead use a replaceRegex function, such as:

/NUMBER_OF_PRESCRIBERS = replaceRegex(/NUMBER_OF_PRESCRIBERS, '[,-]', '')

Thanks
-Mark

On Dec 20, 2017, at 2:44 PM, Aruna Sankaralingam <Aruna.Sankaralingam@Cormac-Corp.com<mailto:Aruna.Sankaralingam@Cormac-Corp.com>>
wrote:

Should I create another variable like the highlighted one below?

/NUMBER_OF_PRESCRIBERS  = replace(/NUMBER_OF_PRESCRIBERS, ',', '')
/NUMBER_OF_PRESCRIBERS1  = replace(/NUMBER_OF_PRESCRIBERS, '-', '')

From: Aruna Sankaralingam [mailto:Aruna.Sankaralingam@Cormac-Corp.com]
Sent: Wednesday, December 20, 2017 10:41 AM
To: users@nifi.apache.org<mailto:users@nifi.apache.org>
Subject: RE: Put Database record

Hi,

I did as you suggested and it worked. If I want to remove or replace more than one character,
can I do it in the same statement?
For ex: I want to replace ‘,’ and ‘-‘ with ‘’ for the same field.

From: Mark Payne [mailto:markap14@hotmail.com]
Sent: Thursday, December 14, 2017 12:00 PM
To: users@nifi.apache.org<mailto:users@nifi.apache.org>
Subject: Re: Put Database record

Aruna,

You would need to remove the commas from the number. The easiest way to do that is probably
to use
an UpdateRecord processor before the PutDatabaseRecord. In that processor, you would want
to use a
schema that either declares the field as a "string" or uses a union like:

{ "name" : "NUMBER_OF_PRESCRIBERS", "type": [ "int", "string" ] }

Then, in UpdateRecord you would add properties such as:

/NUMBER_OF_PRESCRIBERS  = replace(/NUMBER_OF_PRESCRIBERS, ',', '')

That would strip out any commas for you. It looks like you would need to do the same for each
of the fields
here that you are declaring as an "int"

Thanks
-Mark


On Dec 14, 2017, at 11:15 AM, Aruna Sankaralingam <Aruna.Sankaralingam@Cormac-Corp.com<mailto:Aruna.Sankaralingam@Cormac-Corp.com>>
wrote:

I am getting this error when I am trying to load a csv to redshift. I guess its because I
declared that as an INT in AvroSchema and the value has a “,”. If so, how do I make it
accept that as an integer?


<image001.png>



<image002.png>


<image003.png>

Mime
View raw message