Subtracting values from the same list
Posted: Tue Apr 11, 2017 5:44 pm
Hi, I have what I feel like is a pretty easy problem but my I'm not knowledgeable enough about Python to figure it out.
I was given a script that takes time.time before and after a GPIO output command to test the jitter of the commands. It stored the data in a text file like:
The above doesn't work, but that was my attempt. Thanks for any help.
I was given a script that takes time.time before and after a GPIO output command to test the jitter of the commands. It stored the data in a text file like:
- tp0
1491592477.284164
1491592477.284201
1491592477.284322
1491592477.294415
tp1
1491592482.30128
1491592482.301307
1491592482.301389
1491592482.311484
- tp0
1491592477.284164 (Subtract this)
1491592477.284201 (From this)
1491592477.284322 (and this one)
1491592477.294415 (from this one)
Code: Select all
infile = "/Users/Caghain/Desktop/LAB CODE/TIME/GPIO_times_Edit.txt"
editfile = "/Users/Caghain/Desktop/LAB CODE/TIME/GPIO_times_Subtract.txt"
fin = open(infile, "w+")
fedit = open(editfile, "w+")
for x in fin:
line_TTL=[x+2]
line_SNDOUT=[x+3]
GPIO_HIGH = line_SNDOUT - line_TTL
fedit.write(GPIO_HIGH)
fedit.close()