Input array is longer than the number of columns in this table for add data row

hello ,
i m fetching data from a api and now i want to write the data in the csv but it is throwing me an error that input array is longer than the number of columns in this table .
i am also attaching my flow for the reference
Main.xaml (11.3 KB)

can any one help ,
Regards

Hi @Raina_Ocean_Sanjay ,

Could you Debug the workflow and Check the value that you are adding to the row and the number of Columns in the Datatable to which you want to add ?

The value/array contains more than the number of columns, hence the error.

You Could check the value in Immediate Panel after Debug and send us a Screenshot.

Hi,

First, “data” in ForEach isnt’t good, because its same as data class and is caused trouble.

Next, there are 4 columns in the datatable, but 9 items in the JToken. So you need to create datatable which has 9 columns.

I just modified them as the following. Can you try this?

Main(11).xaml (12.1 KB)

Regards,

Hi,

Or it might be better to use .Values instead of Split method, as the following.

image

Main(11).xaml (12.1 KB)

Regards,

Hi @Raina_Ocean_Sanjay

You can also try with Regex Expression

Check out the XAML file

image

Main (9).xaml (13.9 KB)

Output

image

Regards
Gokul

@Raina_Ocean_Sanjay ,

Alternately, You could also directly convert the JArray to a Datatable using the below :

OutputDT = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Datatable)(jobj("data").ToString)

You wouldn’t need to use For Each Activity. In the above case, you wouldn’t need to use Build Datatable Activity, we can directly assign it to an Empty Datatable.

You could then use Filter Datatable Activity to keep only the Required Columns.

As i only need to fetch the data for
date , area name , comfirmed and death

so this is not working for me , if i need to fetch all of the data then i can do this

Regards :slight_smile:

Yes , this is the perfect output i was looking for :slight_smile:
Regards

yes this can also work for me :slight_smile:

Regards ,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.