Support Questions

Find answers, ask questions, and share your expertise

Date is not parsed as expected in Csv Reader Processor

avatar
New Contributor

I have a pipeline where input source is GetFile , reading csv files ,updating date format using UpdateRecord and then saving in my sql database. Configuration to update time format is :property=>${field.value:toDate("mm/dd/yyyy hh:mm:ss"):format("YYYY-MM-DD HH:mm:ss")}

 

Problem is I am getting date parsing exception at Update Record and date value read by CSV reader is 4/5/2019 0:00. Getting : Cannot parse attribute value as a date; date format: mm/dd/yyyy hh:mm:ss; attribute value: 4/5/2019 0:00

However when i open csv in excel , i get the date as 4/5/2019 12:00:00 AM , but in Notepad++ it is 4/5/2019 0:00. I am confused now where exactly the problem is with csv reader or updateRecord configuration. 

1 ACCEPTED SOLUTION

avatar
Super Guru

@Savi 

 

I think you only need one date format in your nifi expression language.  

 

Next, it seems you know what format it is upstream (source), and what it needs to be for downstream.   Based on your expression need,  you should play the flow up to the csv reader processor and then List Queue on the FlowFiles and inspect the attributes.  Adjust the expression, and retest until the attribute format meets the required format.    Inspecting the dates upstream won't show you what the date looks like after expression and before the reader.   Often times I find myself testing a flow step by step, each step confirming the attributes needed are correct for the next step.  Never moving forward to the next step until I am sure the attributes are correct after visual inspection.

View solution in original post

1 REPLY 1

avatar
Super Guru

@Savi 

 

I think you only need one date format in your nifi expression language.  

 

Next, it seems you know what format it is upstream (source), and what it needs to be for downstream.   Based on your expression need,  you should play the flow up to the csv reader processor and then List Queue on the FlowFiles and inspect the attributes.  Adjust the expression, and retest until the attribute format meets the required format.    Inspecting the dates upstream won't show you what the date looks like after expression and before the reader.   Often times I find myself testing a flow step by step, each step confirming the attributes needed are correct for the next step.  Never moving forward to the next step until I am sure the attributes are correct after visual inspection.