Copy Row from one DataTable to another

Will this method copy the entire line of those not matching the criteria?

@pulapathiswathi

Use Invoke method activity and use Import row method.
Before that Create the schema of DT2 same as that of DT1
DT2=DT.Clone()

Regards,
Mahesh

1 Like

Hi @MAHESH1,

In which step do you clone the tables?

I’ve tried when initialising it but it didn’t work:

ImportRow returns an empty sheet in my case :confused:

@FlpVsg

In Variable section initialise Despeass datatable as new DataTable()

Before Importing that is before running foreach activity where you are using invoke method use Despesas=ExtractDataTable.Clone()

Regards,
Mahesh

1 Like

Hello Akash,

While i’m using invoke method for new column add. I’m Getting trouble on Method name

What i’ve to give in Method name for Datatables,adding columns

Please let me know about Setordinal\

Thank you
Ganesh

Hi,
Does the invoke method|import row work only on data tables that we build like you did in the attached xaml? Can we use this if we create data tables using excel data?

Thanks,
Pratik

Easiest method! Thanks for your help!

1 Like

Dear Akash… can you please provide the like to all possible read functions in invoke method… this invoke method is very usefull…

Thanks
MI

Super :slight_smile:

1 Like

@Florent_Salendres,

Dude, I did exactly as you said. Like I wanted to read a data row into an another data table.

Hence, what I did was to assign the Data row variable and also assigned the values to the data row and finally used the activity called (add data row) to add this data row to my Data table (which I build dynamically).

I was trying to pass this dataRow from the property settings of (add data row) and (setting up the corresponding data table).

But i was getting an error(this data table belongs to an another data table) which is fine, because it was.

So I used your approach of doing this."::-1:

{dataRowothers(0).ToString+", “+dataRowothers(1).ToString+”, “+dataRowothers(2).ToString+”, “+dataRowothers(3).ToString+”, “+dataRowothers(4).ToString+”, "+dataRowOthers(5).ToString}

Here I was getting all the data row values into a string array variable and then passing to the add data row activity.

But I am getting output as:- All the outputed columns are pasted in the first colunm only (I want all the elements) to be divided as it is in the final data table.

Kindly help, or ask if something is not clear.

Thanks and Regards,
@hacky.

1 Like

Hi,

From what I see you would need to remove every quotation marks and “+”, because you are currently concatenating your values into one string.

You expression, to be passed into ItemArray property of “Add Data Row” activity should look like this.

{dataRowothers(0).ToString, dataRowothers(1).ToString, dataRowothers(2).ToString, dataRowothers(3).ToString, dataRowothers(4).ToString, dataRowOthers(5).ToString}

Note that there is a more “elegant” way to do this.

If both table have the same column length

dataRowothers.ItemArray

If dataRowothers length is higher than second table.

dataRowothers.ItemArray.Take(6).ToArray

Cheers

1 Like

A comprehensive solution is attached. Below things are happening in the .xaml file
Directory: ‘C:\Temp’
Main File: ‘Sample.xlsx’ (Attached)
Requirement: Create a ‘Sample_Filtered.csv’ file with the same headers in the main file >> Delete all the rows except the header >> Copy rows from the main file where ‘Rate’ is greater than 175 >> Update the file.

Note: No impact is expected in Preformatted textthe main file.

Hope it will help in some or the other way.

Thanks,
Ashish

Sample.xlsx (9.5 KB)

Delete-Append-Row.xaml (22.0 KB)

2 Likes

Hello @robomani and welcome back!

Check Property of Invoke Method Activity, in Collection you need to import the Row

3 Likes

Worked for me as well. Thanks

Worked!

1 Like

Use Add data row activity and in Arrayrow property give value as row.itemarray

1 Like

Hi Aksh,

What if the schema is different, I need to copy the data from the data table to a worksheet , the struture of the worksheet is different to that of the data table. Morover, few columns in the worksheet has to be filled with some other values.

like in the picture below,Considering this as worksheet where the data needs to be copied but few columns like G or H and M has to be filled with some other values, meaning the values for that are not available in the data table.Hope u have the solution for this Akash, Thanks

1 Like

Thanks Aksh, I tried your example and it worked great for my purpose.
MaryB

2 Likes

Worked for me!

1 Like

Thank you @Florent_Salendres