My current code looks for this type of data:
AHR2,231,123,5,12,51
GPS,12,312,512,35,12
AHR2,13,125,125123,152,12
CMD,123,123,5,123,51,12
PRAM,1231,CM,12
PRAM,12345,DM,14
AND SO ON
Here is how I am doing it right now:
import csv
import matplotlib.pyplot as plt
AHR2 = []
CM = []
with open('data2.csv', 'r') as csvfile:
content = csv.reader(csvfile, delimiter=',')
for row in content:
if 'AHR2' == row[0]:
AHR2.append([row[0]] + list(map(float, row[1:])))
AHR2 = list(zip(*AHR2))
ax.plot(AHR2[1], AHR2[5], label='AHR2 Alt', color = 'red')
This is working fine, except when I am trying to parse the PRAM data part. As you can see there is more than 1 PRAM with different values (CM,DM) I am only interested in the ones that have CM. I have tried this but it gave me an index error.
if 'CM' == row[2]:
CM.append([row[0]] + list(map(float, row[1:])))
Is there a way for me to look between the rows and pull the entire row like I am doing above?