Prabhu, I suggested ExtractText and UpdateAttribute as an alternate solution because I don’t have high confidence that it will effectively and efficiently solve the problem. I strongly recommend using the ExecuteScript option I provided as the primary solution, and I included the Groovy code which would perform the translation for you.
Andy LoPresto [email protected] [email protected] PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69 > On Jan 26, 2017, at 11:10 PM, Lee Laim <[email protected]> wrote: > > In that case, Extract the 'month' and 'year' using ExtractText. Followed by > RouteOnAttribute to send all months except January to an updateAttribute > processor that would decrement the month. previous_month: > ${month:minus(1):toRadix(10,2)}, and set year_prime as the year > > The exception is January which would be routed to a branch where > previous_month would be set to 12, and the year would be decremented > ${year:minus(1)}, and stored as an attribute called year_prime . > > The 2 branches could then be funneled back to the same flow. > > > On Thu, Jan 26, 2017 at 11:33 PM, prabhu Mahendran <[email protected] > <mailto:[email protected]>> wrote: > Lee, > > > This case may not be work for me. > > Actually I want like this: > > Input given - Output Expected > 01-2017 - 12-2016 > 05-2017 - 04-2017 > > If my input is the current month with year, output expected is the last month > cross checked with the year(have to consider the year also, for the case > January month). > > Your answer may satisfy the less than condition for all the previous months. > > On Fri, Jan 27, 2017 at 11:43 AM, Lee Laim <[email protected] > <mailto:[email protected]>> wrote: > Prabhu, > > Using epoch time might end up being a simpler comparison. If the converted > date is less than > 1483254000 (midnight of first day of current month), it is the previous month > (for my timezone). > > Thanks, > > Lee > > > On Thu, Jan 26, 2017 at 10:42 PM, prabhu Mahendran <[email protected] > <mailto:[email protected]>> wrote: > Hi Andy, > > i have already tried with your alternative solution. > "UpdateAttribute to add a new attribute with the previous month value, and > then RouteOnAttribute to determine if the flowfile should be inserted " > > i have used below expression language in RouteOnAttribute, > > ${literal('Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'):getDelimitedField(${csv.1:toDate('dd.MM.yyyy > > hh:mm:ss'):format('MM')}):equals(${literal('Dec,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov'):getDelimitedField(${now():toDate(' > Z MM dd HH:mm:ss.SSS yyyy'):format('MM'):toNumber()})})} > > > it could be failed in below data., > > 23.12.2015,Andy,21 > 23.12.2017,Present,32 > > > My data may contains some past years and future years > > It matches with my expression it also inserted. > > I need to check month with year in data. > > How can i check it? > > > On Fri, Jan 27, 2017 at 10:52 AM, Andy LoPresto <[email protected] > <mailto:[email protected]>> wrote: > Prabhu, > > I answered this question with an ExecuteScript example which will do what you > are looking for on Stack Overflow [1]. > > [1] http://stackoverflow.com/a/41887397/70465 > <http://stackoverflow.com/a/41887397/70465> > > Andy LoPresto > [email protected] <mailto:[email protected]> > [email protected] <mailto:[email protected]> > PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69 > >> On Jan 26, 2017, at 8:40 PM, prabhu Mahendran <[email protected] >> <mailto:[email protected]>> wrote: >> >> Hi All, >> >> I have data in which i need to compare month of data if it is previous month >> then it should be insert otherwise not. >> >> Example: >> >> 23.12.2016 12:02:23,Koji,24 >> 22.01.2016 01:21:22,Mahi,24 >> >> Now i need to get first column of data (23.12.2016 12:02:23) and then get >> month (12) on it. >> >> Compared that with before of current month like., >> >> If current month is 'JAN_2017',then get before of 'JAN_2017' it should be >> 'Dec_2016' >> >> For First row, >> >> compare that 'Dec_2016' with month of data 'Dec_2016' [23.12.2016]. >> >> It matched then insert into database. >> >> if it not matched then ignore it. >> >> is it possible in nifi? >> >> Many thanks, >> prabhu >> >> >> > > > > >
signature.asc
Description: Message signed with OpenPGP using GPGMail
