Merge data

**Source and destination I didn’t get. **
DT I created in Read Range Activity.

2 Likes

Fine the steps involved are
—create a datatable with build datatable activity and create with similar columns in the excel file and get output with a variable of type datatable named finaldt
—now as you said get files and loop through it
—but inside the loop next to read range activity with output variable of type datatable named outdt, use a merge datatable activity and in source mention as outdt and in destination mention as Finaldt

—next to the loop we can use append range activity
Cheers @balkishan

3 Likes

Were we able to get them buddy
Cheers @balkishan

2 Likes

I have a first column name date/time in the excel.
image

Throwing date/time error bro
image

2 Likes

@balkishan you have a easier way to do this, Create a List of files for each file do read range and do append range. Create a Counter So that when you read the first file you use a write range and if the counter >1 use a Append Range.

2 Likes

Fine
once after getting the datatable from read range activity inside the for each loop
use a writeline activity and lets check what is the datatype of that column and create the datatable using build datatable activity with same set of columns and column types
–in writeline mention as
datatablename.Columns(“Yourcolumnname”).GetType.ToString
this will give us the datatype of the column
–so based on that create the datatable using build datatable activity with same column type for that particular column
if needed we can validate with some more writelines and check the datatype of other columns and create the build datatable with same datatype columns

cheers @balkishan

2 Likes

2 Likes

sorry type mistake
yourdatatablename.Columns(“yourcolumnname”).Datatype.ToString

Cheers @balkishan

2 Likes

It worked bro. But give me the blank excel file. If I see the size it containing data. [ 406 KB ]

2 Likes

or lets do one thing instead of append range to existing file
create a new file as master file.xlsx in excel application scope and make sure that the add headers is enabled in the write range activity

Cheers @balkishan

2 Likes

Its writing only the headers not the data.
Both have same size file 406 KB.

image

1 Like

It’s writing the data bro. But it started from Y cell.
As I have data in both the excels from cell A to X

It merged and writing the data in another excel from Y cell.
image

2 Likes

@Palaniyappan We’re about to done, 95% work done. Just want to ask In the merged final file. It started the data from the Y cell. But I want to write from the A1 cell as I given “A1”. But it start from there only.

I know I can again copy again this data written into another but unnecessary writing the so many activity. Issue is about to resolved bro.

2 Likes

@balkishan As you have used build data Table and you doing a merge it takes the schema of both the tables if the schema is not matching then it creates additional columns, check the Schema Mismatch Property to Ignore and try again. image

2 Likes

No, Ignore is not working here . It gives me empty file.

Only ADD working but it gives the data start from Y

1 Like

Great
Sorry for the delayed response

if possible can i have a viewon the write range activity
Cheers @balkishan

2 Likes

I already set “A1” but it doesn’t working.
It start to writing the data from Y only.

image

2 Likes

hmm
make sure that write range is used outside the for each loop
i think its used next to the merge datatable
Cheers @balkishan

2 Likes

If I used the Write Range outside the loop same result it gives me. Start from the cell Y
image

2 Likes

yes because you have use a build datatable and the columns names are not matching or not being considered. As you have A:X columns in Build DataTable it will write from Y, You can try reversing the operation like Change Source Table to Destination and Destination to Source.

2 Likes