question

sachingupta-1921 avatar image
0 Votes"
sachingupta-1921 asked SathyamoorthyVijayakumar-MSFT answered

Writing zeros for all columns in csv file based on a specific condition in ADF

Hello,

I am calling a LinkedIn endpoint using REST activity in ADF. Below are the 2 things which I am working on

Scenario 1:

JSON Response:

 {
     element:
         [
           count:0
         ]
 }

For the above given response, I need to write the value 0 for all the 3 columns which I have in CSV.

Scenario 2:

JSON Response:

 {
     element:
         [
           Clicks:70,
           Impressions:234,
           Likes:20
         ]
 }

For above response all the values will go to the corresponding columns in CSV -> This scenario is working as it is straight forward, but for the first scenario, as the result is zero, nothing is getting written in CSV. I want that for such cases all the column should have the 0 value.

Please guide me on this issue.

Thanks,
Sachin

azure-data-factory
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @sachingupta-1921,

Thanks for the question and using MS Q&A platform.

What is the activity that you are making use of ?

0 Votes 0 ·
sachingupta-1921 avatar image sachingupta-1921 SathyamoorthyVijayakumar-MSFT ·

@SathyamoorthyVijayakumar-MSFT .... I did not understand your question. Activity is Https Rest to retrieve data from LinkedIn API and store the data in CSV format in blob storage

0 Votes 0 ·

@SaurabhSharma-msft @ShaikMaheer-MSFT .. can you guys please help on this?

0 Votes 0 ·

1 Answer

SathyamoorthyVijayakumar-MSFT avatar image
0 Votes"
SathyamoorthyVijayakumar-MSFT answered

Hello @sachingupta-1921,

Thanks for getting back. My apologies for not being clear. My ask was more related by what are you making performing this data movement like - Copy Activity or the mapping data flow.

Option 1 : Using Copy Activity

NOTE : The working of the approach depends on how the data is returned. If the copy activity is triggered copies only one row of data i.e. meaning it either returns Scenario 1 or Scenario 2 as per the question (not multiple rows).

145483-image.png

Then you can have a Web Activity first. You can access the response by following the below:

 activity('Web1').output.response

You could do a condition - Check the response of a web activity. Based on the response, you could have a copy activity defined with the If activity (True - False)

Option 2 :

You could make use of the Mapping Data flow. You could do transformation - like having derived column transformation upon the source and store the manipulated values.

You could check whether there is count and if there is '0'. Then update the value of the other column - for instance clicks as 0 - else - update the value of the clicks as a source. You could repeat the same for other columns.

145524-image.png



image.png (15.0 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@SathyamoorthyVijayakumar-MSFT ... thanks for the response. I was working on it yesterday and got the same approach to do it. Thank you!

0 Votes 0 ·