I am trying to select the last string after splitting it in Azure Data Factory.
My file name looks like this:
s = "cloudboxacademy/covid19/main/ecdc_data/hospital_admissions.csv"
With Python I would use s.split('/')[-1]
to get the last element, according to Microsoft documentation I can use last
to achieve this, so I’ve tried this in the sink database Pipeline expression builder:
@last(split(dataset().fileName, '/'))
Which gives me a red underline stating:
Cannot fit string list item into the function parameter string
However, after running the pipeline I get what I desire, the file named hospital_admissions.csv
placed in the folder I want it to go, so my question is if I am chaining the functions correctly & why am I having the error with a working code?
2
Answers
you can do the following:
Create 2 Variables:
Variable 1 (Array):
Variable 2 (String):
The pipeline expression builder might be recognizing the value generated by
split(dataset().fileName,'/')
as an array. Hence the message Cannot fit string list item into the function parameter string.Cannot fit string list item into the function parameter string
is not shown, you can use the result ofsplit
along witharray
function. You can still chain the function using the following dynamic content and get expected result: