cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

how can i delete data in infotable

TW_10599876
5-Regular Member

how can i delete data in infotable

I want to delete data in the infotable by checking from the _time field. If there are any duplicate time periods, check from the day, month, year. Then delete rows that have a value of 0 from the infotable. What methods can be used to do this?

TW_10599876_0-1715850526973.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rocko
17-Peridot
(To:TW_10599876)

Loop over the existing Infotable and create a new one containing only the required rows.

roughly like this (probably some syntax errors in it, but you'll get the idea):

let dateArray=[]; 
let oldTableArray=oldTable.rows.toArray();

// first pass: add non zero values, store dates in array
oldTableArray.filter(row=>row.value!=0).forEach(row=>{
   newTable.AddRow(row);
   dateArray.push(row._time.substring(0, 10));
});
// second pass: add zeroes if date not already contained in array built in first pass
oldTableArray.filter(row=>row.value==0 && !dateArray.includes(row._time.substring(0,10))).forEach(row=>{
   newTable.AddRow(row);
});

 

View solution in original post

3 REPLIES 3

Hi @TW_10599876 

Can you check the below article and let us know it will work in your case or not.

https://www.ptc.com/en/support/article/CS304696

TW_10599876
5-Regular Member
(To:Surya_Tiwari)

Now, I have succeeded by using the method of looping through the infotable to check the data.

 

Rocko
17-Peridot
(To:TW_10599876)

Loop over the existing Infotable and create a new one containing only the required rows.

roughly like this (probably some syntax errors in it, but you'll get the idea):

let dateArray=[]; 
let oldTableArray=oldTable.rows.toArray();

// first pass: add non zero values, store dates in array
oldTableArray.filter(row=>row.value!=0).forEach(row=>{
   newTable.AddRow(row);
   dateArray.push(row._time.substring(0, 10));
});
// second pass: add zeroes if date not already contained in array built in first pass
oldTableArray.filter(row=>row.value==0 && !dateArray.includes(row._time.substring(0,10))).forEach(row=>{
   newTable.AddRow(row);
});

 

Top Tags