locked
How to generate .csv files in Blob with TimeStamp? RRS feed

  • Question

  • Hi Techie!

    While storing .csv files to Azure Blob, I wanted to store the file name with DateTime. e.g., filename_0916_10_30.csv.

    How to achieve this?

    Thanks

    Monday, September 16, 2019 5:08 PM

Answers

  • Hi Santhosh,

    Assuming your question is related to Azure Data Factory (V2) and below is my suggestion.


    In Data Factory data set File path settings, you can use below Dynamic expression content.

    @concat('fileName','_',formatDateTime(utcnow(),'yyMMddhhmmss'),'.csv')

    This outputs the filename as : fileName_190916070445.csv

    Or

    @concat('fileName','_',formatDateTime(utcnow(),'MMdd_hh_mm_ss'),'.csv')
    This outputs the filename as : fileName_0916_07_06_27.csv

    Hope this helps. Let us know if you have any questions.


    Thank you

    If a post helps to resolve your issue, please click the "Mark as Answer" of that post and/or click Answered"Vote as helpful" button of that post. By marking a post as Answered and/or Helpful, you help others find the answer faster.


    Monday, September 16, 2019 7:02 PM

All replies

  • We use a series of variable actions:  first split the incoming filename into the name and extension portions.  Then create additional name segments or substrings.  Final variable action to reconstruct the filename from the earlier variables.

    Google "azure working-with-dates-times-in-microsoft-flow" for an excellent breakdown of the functions and masks you can use in a [Data Operations - Compose] action to get the date in a string format that you want (I can't embed links yet)

    I'm still new to Azure, so I don't know if there's a more all-in-one action that will do the job.

    Good luck!


    • Edited by jeff_h_1138 Monday, September 16, 2019 5:54 PM
    Monday, September 16, 2019 5:53 PM
  • Hi Santhosh,

    Assuming your question is related to Azure Data Factory (V2) and below is my suggestion.


    In Data Factory data set File path settings, you can use below Dynamic expression content.

    @concat('fileName','_',formatDateTime(utcnow(),'yyMMddhhmmss'),'.csv')

    This outputs the filename as : fileName_190916070445.csv

    Or

    @concat('fileName','_',formatDateTime(utcnow(),'MMdd_hh_mm_ss'),'.csv')
    This outputs the filename as : fileName_0916_07_06_27.csv

    Hope this helps. Let us know if you have any questions.


    Thank you

    If a post helps to resolve your issue, please click the "Mark as Answer" of that post and/or click Answered"Vote as helpful" button of that post. By marking a post as Answered and/or Helpful, you help others find the answer faster.


    Monday, September 16, 2019 7:02 PM