Skip to content

Instantly share code, notes, and snippets.

@sirishn
Created September 5, 2013 19:39
Show Gist options
  • Save sirishn/6455076 to your computer and use it in GitHub Desktop.
Save sirishn/6455076 to your computer and use it in GitHub Desktop.
Open .csv log file and plot
#! /usr/bin/python
# Open .csv log file, plot elbow feed forward force and elbow load
import sys
import numpy as np
from pylab import *
from struct import pack, unpack
import csv
def plot_csv(filein):
time = []
load = []
uff = []
filename = filein
#with open('d00007.csv', 'rb') as f:
with open(filename, 'rb') as f:
reader = csv.reader(f)
for row in reader:
if row[0] == "time (s)": # TAG ROW 0
print row
else:
time.append( float(row[0] ) )
load.append( float(row[5] ) )
uff.append( float(row[8] ) )
subplots_adjust(hspace=0.5)
subplot(2,1,1)
plot(time, load)
title("Right elbow load (Nm)")
xlabel("time (s)")
ylabel("Force (Nm)")
grid()
subplot(2,1,2)
plot(time, uff)
title("Right elbow feed forward force (Nm)")
xlabel("time (s)")
ylabel("Force (Nm)")
grid()
show()
if __name__ == '__main__':
filename = sys.argv[1]
print filename
plot_csv(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment