Use a Data Flow activity with the Surrogate Key transformation. That will add a row number to your dataset.
I need to append a rownumber to each line and copy file to adls storage account. Is it possible to do in copy activity ?
I have a psv file in blob storage. I need to append a Row Number to each line and copy file to ADLS storage account. Is it possible to do in copy activity ?
01 - has 214 columns, 02 - has 18 cols 07 - has 4 cols. So the appending of Row Number needs to be dynamic.
Input :
Desired output :
Append Row Number to each row at end of line.
Tried to do using additional column in copy activity > rowNumber() but the outpu was like below. It appended the word "rowNumber" at last of each line.
Can anyone help ?
Azure Data Factory
-
MarkKromer-MSFT 5,226 Reputation points Microsoft Employee Moderator
2023-01-13T00:01:29.76+00:00
2 additional answers
Sort by: Most helpful
-
Nandan Hegde 36,151 Reputation points MVP Volunteer Moderator
2023-01-12T12:55:44.12+00:00 Based on my understanding, unfortunately it is not directly possible via Copy activity.
You might need to use Data flow activity by creating a derived column for row number and adding it in sync file.
-
KranthiPakala-MSFT 46,642 Reputation points Microsoft Employee Moderator
2023-01-18T22:18:05.4933333+00:00 Hi VC,
The answer is no, there is no easy way to do it in Copy activity and copy activity is intended to do data movement between data stores. For this requirement, as @Mark Kromer MSFT called out in order to add an additional column for row serial number, you will have to use Mapping dataflow and use Surrogate Key Transformation. Below is sample:
Here is how the settings looks like for Surrogate Key.
Here is the documentation for Surrogate Key transformation: Surrogate key transformation in mapping data flow
Hope this info helps. Do let us know if you have further query.
Please don’t forget to
Accept Answer
andUp-Vote
wherever the information provided helps you, this can be beneficial to other community members.