Concat two datasets

how can I concat Two datasets?

https://docs.inductiveautomation.com/display/DOC81/system.dataset.appendDataset

3 Likes

thank you but it not work because my dataset2 have 5 columns and other 3 columns.

You are going to have to write a script to iterate through the datasets and do this manually then. I would recommend reading through this and try your hand at writing a script - Datasets - Ignition User Manual 8.1 - Ignition Documentation

1 Like

@Sebastiao_Nankuta_Ga
Here is an example I created for somebody a little while back. It takes a dataset from a custom property, and a dataset from a tag and stitches them together into a data table using a common column. Once you get your head around the scripting, you probably won't too much trouble modifying this example to fit your usage case:

So you basically want the equivalent of an SQL join ?
Where do the datasets come from ?
What should be joined on ? Or will they always have the same number of rows, in the right order ?

Without more details, the simplest solution would be

for i in range(dataset2.getColumnCount):
    dataset1 = system.dataset.addColumn(
        col=dataset2.getColumnAsList(i),
        colName=dataset2.getColumnName(i),
        colType=dataset2.getColumnType(i)
    )

Yes I want the equivalent of an SQL join

And the number of rows are differents

Then what do you join them on ? How should they be joined if they're not the same length ?

3 Likes

yes with differents length.

table1: 5x3 and table2: 4x6

That doesn't answer my question.
I'll try to rephrase:
With an SQL join, you use a column to match rows from one table to rows from another one:

select * from table_a
inner join table_b on table_a.column_name = table_b.column_name

What column should be used to match rows in your datasets ? There's nothing there that could be used for this, so we need a way to know HOW the datasets should be joined.
Maybe show us with different datasets, of different lengths.

If you're not comfortable with English, try in your own language and we'll do what we can.
As it is, there's no proper solution to your problem.

1 Like

You need something that is similar between the two tables.

For instance, in SQL you tell it what to join on.

SELECT * FROM SomeTable
JOIN SomeTableA on SomeTable.SomeColumn = SomeTableA.SomeColumn

So the tables are different lengths and widths, how should the system decide which rows from Table 2 match up to the rows from Table 1?

I'am Sorry, I want do it in ignition perspective . I have dataset1 and dataset2 dataset = dataset1 concat dataset2

You need to read more carefully.
We can't help you if you don't answer our questions.

if the rows from table 2> table1 in this case, I will write defauts values in the rows of table1 to have the same number of rows.
Exmple:

table2 : 2x3

name age
AA 12

BB 35

CC 10

if I have Table1 :1x3

I will put defaut value on the other rows:

Country City age
Angola Luanda 12

XX XX 00

XX XX 00

Hey if solved pls do post the solution
Im looking something like this

Consider starting a new topic that explains precisely what you have and precisely what you want to get, and in what environment. Tag the new topic with your Ignition version and front-end UI type (Perspective vs. Vision). This topic is too confused for "something like this" to be meaningful.

4 Likes