Reputation: 13
I am new to azure data factory and need to implement below logic using Azure Data Factory where we are transferring a csv file from source to destination with some transformation in the file.
Input file contains below data :
111|101|2019-02-04 21:04:57
222|202|2019-02-04 21:33:54
333|202|2019-02-04 20:23:55
Expected Output :
H|TestFile|currentDateTime------------ Need to add this header record. H and TestFile would be static
111|101|2019-02-04 21:04:57
222|202|2019-02-04 21:33:54
333|202|2019-02-04 20:23:55
T|03-------------------------------------- T is static value. Need to add total number of records here.
Can someone please help with this
Upvotes: 1
Views: 2269
Reputation: 6043
Update:
After my series of tests, the final result I can get is as follows:
The structure overview is as follows:
source1
stores the source csv file, I set column name as Column_1
at Projection tab.
The source1
data preview is as follows:
At SurrogateKey1 activity, I key in Row_No
as Key column and 1
as Start value.
At Window1
activity, select Row_No
as Window column, then enter expression max(Row_No)
.
Window1
data preview is as follows, I can get the max value of the Row_No
.
Use Pivot1
activity to switch from columns to rows, enter expression concat('T|',toString(max(Row_No),'00'))
to get T|03
.
Pivot1
activity data preview is as follows:
At DerivedColumn1
,
set column name: Column1
,
set expression: concat(Column_1,'|',toString(currentTimestamp()))
.
At SurrogateKey2
activity, I key in Row_No
as Key column and 2
as Start value.
SurrogateKey2
activity data preview is as follows:
At Select2
activity, filter the column which we want and give this column an alias.
Data preview is as follows:
headers
stores the header info in a csv file. Set Column_1
as column name.
At SurrogateKey3
activity, I key in Row_No
as Key column and 1
as Start value.
Union SurrogateKey3
activity with Select2
activity.
It will sort by Row_No
column, so the title will be on the first line.
Then we can only select what we need via Select1
activity.
Select1
activity data preview is as follows:
Union Pivot1
activity and Select1
activity via Union2
activity.
The Union2
activity data preview is as follows:
Upvotes: 2