i have a python script that collects data from a server in the form of
<hh-mm-ss>,<ddd>
here, the first field is Date and the second field is an integer digit. this data is being written into a file.
i have another thread running which is plotting a live graph from the file which i mentioned in the above paragraph.
so this file has data like,
<hh-mm-ss>,<ddd>
<hh-mm-ss>,<ddd>
<hh-mm-ss>,<ddd>
<hh-mm-ss>,<ddd>
Now i want to plot a time series Matplotlib graph with the above shown data. but when i try , it throws an error saying,
ValueError: invalid literal for int() with base 10: '15:53:09'
when i have normal data like shown below, things are fine
<ddd>,<ddd>
<ddd>,<ddd>
<ddd>,<ddd>
<ddd>,<ddd>
UPDATE my code that generates graph from the file i have described above is shown below,
def animate(i):
pullData = open("sampleText.txt","r").read()
dataArray = pullData.split('\n')
xar = []
yar = []
for eachLine in dataArray:
if len(eachLine)>1:
x,y = eachLine.split(',')
xar.append(int(x))
yar.append(int(y))
ax1.clear()
ax1.plot(xar,yar)
UPDATED CODE
def animate(i):
print("inside animate")
pullData = open("sampleText.txt","r").read()
dataArray = pullData.split('\n')
xar = []
yar = []
for eachLine in dataArray:
if len(eachLine)>1:
x,y = eachLine.split(',')
timeX=datetime.strptime(x, "%H:%M:%S")
xar.append(timeX.strftime("%H:%M:%S"))
yar.append(float(y))
ax1.clear()
ax1.plot(xar,yar)
Now i am getting the error at this line (ax1.plot(xar,yar)
)
how will i get over this?