Home > Software engineering >  Selecting the last element after split in Azure Data Factory
Selecting the last element after split in Azure Data Factory

Time:11-09

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 OutputVariable1

OutputVariable2

VariableDeclaration

CodePudding user response:

The pipeline expression builder might be considering the value generated by split(dataset().fileName,'/') as a string (array as a string) but not as an array itself. Hence the message Cannot fit string list item into the function parameter string.

enter image description here

  • However, while executing, it is giving the expected output.
  • To make it so that the warning Cannot fit string list item into the function parameter string is not shown, you can explicitly convert the result of split to an array using array function. You can still chain the function using the following dynamic content and get expected result:
@last(array(split(dataset().filename,'/')))

enter image description here

  • Related