[SOLVED] How to delete all data from a variable with command in Python

how to delete all data from a variable with command in Python (Ubidots)? There is a command fo it? I’m working on a project for the University in Brazil. I need help.

Hello @tccHamilton how are you?
Are you using python library of Ubidots? or are you making all the code? we try to help you as soon as possible!
nice day,
Metavix

Hello Metavix, I’m fine and you?
I’m using python library of Ubidots and I need to delete the data using a command in python. I’m programing all the code in python the device Intel Edison, and my code sends several data with timestamp in miliseconds that need be deleted constantly. Follows a piece of code:

def transmitter(): ##################### DATA TRANSMITTER ####################
t = int(time.time())*1000
global z
EECG = api.get_variable(‘5745f49d7625426e016045f8’)
while True:
if z == 1:
print “Start sending data electrocardiogram”
try:
EECG.save_values([
{‘timestamp’: t, ‘value’:ecg1[0]},
{‘timestamp’: t+1, ‘value’:ecg1[5]},
{‘timestamp’: t+3, ‘value’:ecg1[10]},
{‘timestamp’: t+4, ‘value’:ecg1[15]},
{‘timestamp’: t+5, ‘value’:ecg1[20]},
{‘timestamp’: t+6, ‘value’:ecg1[25]},
{‘timestamp’: t+7, ‘value’:ecg1[30]},
{‘timestamp’: t+8, ‘value’:ecg1[35]},
{‘timestamp’: t+9, ‘value’:ecg1[40]},
{‘timestamp’: t+10, ‘value’:ecg1[45]},
{‘timestamp’: t+11, ‘value’:ecg1[50]},
{‘timestamp’: t+12, ‘value’:ecg1[55]},
{‘timestamp’: t+13, ‘value’:ecg1[60]},
{‘timestamp’: t+14, ‘value’:ecg1[65]},
{‘timestamp’: t+15, ‘value’:ecg1[70]},
{‘timestamp’: t+16, ‘value’:ecg1[75]},
{‘timestamp’: t+17, ‘value’:ecg1[80]},
{‘timestamp’: t+18, ‘value’:ecg1[85]},
{‘timestamp’: t+19, ‘value’:ecg1[90]},
{‘timestamp’: t+20, ‘value’:ecg1[95]},
{‘timestamp’: t+21, ‘value’:ecg1[100]},
{‘timestamp’: t+22, ‘value’:ecg1[105]},
{‘timestamp’: t+23, ‘value’:ecg1[110]}
]):# #ECG
except:
print “Failure internet connection when send data ecg”
z = 0
print “End to send electrocardiogram”
try:
if ((vec[4] and vec[5]) == 1) and (vec[0] > 25):
api.save_collection([
{‘variable’: ‘56f1c7d07625424e90076557’,‘value’:vec[0]}, #Temp
{‘variable’: ‘57052788762542350885acdc’,‘value’:vec[2]}, #BMP
{‘variable’: ‘56f1c7e57625424f17fd4ce6’,‘value’:vec[3]} #Spo2
])
except:
print “failure internet connection”
break
try:
api.save_collection([
{‘variable’: ‘57474da27625424b2407be77’,‘value’:vec[4]}, #bitTEMP
{‘variable’: ‘57474b087625422dbacd1b2b’,‘value’:vec[5]} #bitSPO2
])
except:
print “failure internet connection”
break

Thanks fo all

Hi Hamilton,

Yes you can use the method remove_values(t_start, t_end), this method uses the endpoint http://ubidots.com/docs/api/index.html#delete-values-from-a-variable

You can use the value 0 for the start and the end value 1483228800000 (January 1, 2017)

>>> v = client.get_variable('2233444376254264eef6ebce')
>>> v.remove_values(0, 1483228800000)
{u'count': 13412}

Gustavo.

Hi Woakas
Thanks for the help, it worked perfectly.