I am facing issue doing some transformations using U-sql one of the issue is while changing the Date format, Only when I skip the First rows(1) I am able to convert the date format. But I do need the column names so I cannot Skip the first row. Also I need to do some other transformations like data type conversion and simple concatenations.Below is my sample code.Kindly help.
DECLARE @dir string = "/storefolder/Sourcefile/dwfile3.csv";
DECLARE @file_set_path string = "/BCBSvermot/Sample_output.csv";
@data =
EXTRACT
CHECK_DATE string,
FROM @dir
USING Extractors.Csv(skipFirstNRows:1);
@result = SELECT
Convert.ToDateTime(CHECK_DATE).ToString("dd-MM-yyyy") AS CHECK_DATE
FROM @data;
OUTPUT @result
TO @file_set_path
USING Outputters.Csv();
Thanks, Rav
You can declare a function similar to this:
DECLARE @func Func<string,string> =
(s) =>{
DateTime i;
var x = DateTime.TryParse(s, out i);
return x?((DateTime)i).ToString("dd-MM-yyyy",CultureInfo.CurrentCulture) : s;
};
Then you can use it on your queries
@result =
SELECT @func(CHECK_DATE) AS CHECK_DATE
FROM @data;