Amulya
Amulya

Reputation: 1

how to copy CSV data that is present in blob to azure storage table using logic app

I designed a logic app to copy the data from blob to azure storage table using logic app now, I m getting my output as wrong as all the data that is present in blob is shown in the output in single column of azure storage table .

I tried using get blob content action and then insert entity from azure storage table .in insert entity step I m getting as all the output of blob content is getting stored in single column of azure storage table

Upvotes: 0

Views: 1389

Answers (1)

vijaya
vijaya

Reputation: 1731

Once content is retrieved from csv file you need to convert data into Json. Then using compose action you can insert data into table. Reproduced issue from my side and below are the steps I followed,

  1. Created logic app as shown below,

enter image description here

  1. Created container in storage account and uploaded a CSV file in container. enter image description here

3.Next using compose action to split the contents of the CSV file on every new line into an array. enter image description here

Here is the expression used in compose action:

split(body('Get_blob_content_(V2)'),decodeUriComponent('%0D%0A'))
  1. Removing last(empty) line from previous output using another compose action as shown below,

enter image description here

take(outputs('Compose'),add(length(outputs('Compose')),-1))

5.Separating filed names using compose action enter image description here

split(first(outputs('Compose')), ',')
  1. Forming json as shown below using Select action, enter image description here
skip(outputs('Compose_3'), 1)
outputs('Compose_2')[0]  split(item(), ',')?[0]
outputs('Compose_2')[1]   split(item(), ',')?[1]
outputs('Compose_2')[2]   split(item(), ',')?[2]
outputs('Compose_2')[3]   split(item(), ',')?[3]
  1. As there are multiple rows in csv file, using for each loop as shown below, enter image description here
  2. Using compose action, forming json to insert data into azure table, enter image description here
  3. Inserting data into table from output of Compose4 action, enter image description here
  4. Logic app ran successfully and inserted data into azure table, enter image description here

Output of Get blob Content: enter image description here

Output of Select:

enter image description here

Output of Insert entity: enter image description here

Data inserted into table: enter image description here

Upvotes: 0

Related Questions