Skip to main content

Hello , 


I have a simple pipeline where i want some csv files to be moved from s3 bucket to SFTP server,
However the files saved in the SFTP server should have different naming that includes the current date, something like:
“mer_YYYYMMDDHHmmss.csv”

i tried in the file name expression field in the sftp server destination to come up with expression evaluating the above but it always produces errors that functions like YYYY() is not a function.

@N_ali 

Use expression language to create a new file name. Something like

${str:concat(record:value('/fileInfo/filename'), ".json")}

Instead of “.json”, you can add something like ${YYYY()-MM()-DD()} 

More information here

 


whenever i use YYYY() or MM() or any other date function

i get this error : Error evaluating expression ${YYYY()-MM()-DD()}: javax.servlet.jsp.el.ELException: No function is mapped to the name "YYYY" .

 


i have the files in amazon S3 bucket as mer-timestamp-version.csv , for example mer-123654789-1.csv
i want them to be saved in SFTP server as mer_YYYYMMDDhhmmss.csv , for example mer_20220828085700.csv


@N_ali Ah ok…

Try using an expression evaluator. If 123456789 in  mer-123654789-1.csv is the timestamp then try creating the file name in an expression evaluator…

get the number bit in another variable called mytimestamp

create a new field called /myfilename as concatenate of 
record:value('/fileInfo/filename') + time:millisecondsToDateTime(<long>)


can you please provide me with an example ,
i am having hard time creating the expression without errors.


i managed to get the timestamp and convert it into a datetime but it’s displayed as Aug 27 8:30 AM for example but i want it like 20220827083000 where this evaluates to YYYYMMDDHHmmss

 

Appreciating your response on this.


Reply