Hi,
I would like to use table calculations in ZEN Core OAD (I didn't find any example in the forum on this topic).
First with columns:
[Column1 (table1) / Column1 (table2)] * 100
And with lines:
Sum or average of all lines of a table into a new table.
Thanks for your help.
calculate table columns
-
- Posts: 180
- Joined: Wed May 20, 2020 10:10 am
Re: calculate table columns
Hello Julien Toquant,
I would like to show some general approaches concerning tables.
In OAD you can use ZenTables, that are used within Zen, and you can use DataTables.
DataTables are one of the main approaches to work with data in .Net and ZenTables are based on DataTables.
Please have a look at DataTable and e.g. Calculate in the internet to get more information.
I hope that the following simple example is a solid basis to proceed.
I would like to show some general approaches concerning tables.
In OAD you can use ZenTables, that are used within Zen, and you can use DataTables.
DataTables are one of the main approaches to work with data in .Net and ZenTables are based on DataTables.
Please have a look at DataTable and e.g. Calculate in the internet to get more information.
I hope that the following simple example is a solid basis to proceed.
Code: Select all
table = ZenTable()
table.Columns.Add("First", str)
table.Columns.Add("Second", int)
table.Columns.Add("Third", int)
table.Rows.Add('Test1', 1, 11)
table.Rows.Add('Test2', 2, 22)
print(table.Rows[0][0])
print(table.Rows[1][0])
dataTable = table.ToDataTable()
sum = dataTable.Compute("Sum(Second)", "")
print(sum)
-
- Posts: 23
- Joined: Fri May 29, 2020 1:54 pm
Re: calculate table columns
Thanks. That's a good start.
Could you also give me a code for dividing and multiplying values of two columns please?
BR
Julien
Could you also give me a code for dividing and multiplying values of two columns please?
BR
Julien
-
- Posts: 180
- Joined: Wed May 20, 2020 10:10 am
Re: calculate table columns
Hello Julien Toquant,
I'm not sure, but do you mean something like
I'm not sure, but do you mean something like
Code: Select all
table = ZenTable()
table.Columns.Add("First", str)
table.Columns.Add("Second", int)
table.Columns.Add("Third", int)
table.Columns.Add("Forth", int)
table.Rows.Add('Test1', 1, 11)
table.Rows.Add('Test2', 2, 22)
for row in table.Rows:
row[3] = row[1] * row[2]
print(row[3])
-
- Posts: 23
- Joined: Fri May 29, 2020 1:54 pm
-
- Posts: 23
- Joined: Fri May 29, 2020 1:54 pm
Re: calculate table columns
Another question: how do I get the output tables from image analysis used in a job ?
thanks.
thanks.
-
- Posts: 180
- Joined: Wed May 20, 2020 10:10 am
Re: calculate table columns
Hello Julien Toquant,
this is an example where you add a macro workbench after an analysis step in a job.
The idea is to catch the image and then extract the tables from the image, like:
I hope this code snippet helps to demonstrate the idea in principle.
this is an example where you add a macro workbench after an analysis step in a job.
The idea is to catch the image and then extract the tables from the image, like:
Code: Select all
image = Zen.Application.ActiveWorkbench.GetDefaultInputValue()
RegionsTable = Zen.Analyzing.CreateRegionsTable(image)
Klasse1Table = Zen.Analyzing.CreateRegionTable(image, "Klasse1")
etc.
-
- Posts: 23
- Joined: Fri May 29, 2020 1:54 pm