a simple snapsot write below also gives the same error
1 of 1 people found this helpful
Try the following code example. Basically, even though the documentation states it is optional, every parameter must be specified when using PISDK via Python (and similar languages).
import pythoncom PL = Dispatch("PISDK.PISDK") srv = PL.Servers.DefaultServer points = srv.PIPoints pt = srv.PIPoints['sinusoid'] pt.Data.UpdateValue( 400000, "*", PL.PIConstants['DataMergeConstants']["Replace Duplicates"].Value, None)
That worked like a charm Luis except for I am using pure python and I had to import win32com.client and use PL = win32com.client.Dispatch("PISDK.PISDK")
Thank you very much
do you have a code snippet that shows how to delete values from the archives using python that is?
If Luis' code works fine, you could use Remove Values method in PI Data class, please see the following as the example:
pt.data.RemoveValues("*-1h", "*", DataRemovalConstants.drRemoveAll);
The above is what I did in C# code. I think it could be easy changed to python. You could try:
pt.data.RemoveValues("*-1h", "*", PL.PIConstants ['DataRemovalConstants']["drRemoveAll"].value, none);
You could try it, and could go to see the details of Removevalues Method in PI SDK manual.
Thanks that worked for me. I had to play around with the date format and it worked :-
from datetime import datetime
pi_sdk = win32com.client.Dispatch('PISDK.PISDK')
conn = win32com.client.Dispatch('PISDKDlg.Connections')
pi_server = pi_sdk.Servers('SRB1-PISVR')
myhitlistfile = open("*\hitlistfile.txt","rb")
myhitlist = csv.reader(myhitlistfile)
for row in myhitlist:
pi_alarmlist = pi_server.PIPoints[row.rstrip('\n')]
date_object = datetime.strptime(row, '%m/%d/%y %H:%M:%S')
pidate = date_object.strftime('%d-%b-%y %H:%M:%S')
pi_alarmlist.Data.RemoveValues(pidate,pidate,pi_sdk.PIConstants['DataRemovalConstants']["Remove first only"].Value,None)
I'm facing issue in below line
is there any reference to add??
If you are encountering errors such as "No module named pythoncom" or "No module named win32com", make sure you have the Python for Windows Extension library (pywin32).
If not, can you provide us with the error message?