2
CSV 파일이 있습니다. 그래프를 그릴 때 사용하고 있습니다. 첫 번째 행에 이름이 있고 마지막 행에 공백이 포함되어 있기 때문에 CSV 파일에서 첫 번째 행과 마지막 열을 제거하고 싶습니다. 첫 번째 행과 마지막 행을 제거하면 프로그램이 제대로 작동합니다.이 추출 된 파일에서 행을 제거 할 수 있습니다. 보정 내가 당신에 의해 값을 얻을 수 있도록하여도 코드를 읽기 쉽게 만들 것이다, 대신 csv.DictReader을 사용할 수,파이썬에서 첫 번째 행과 마지막 행 요소 남기기
import csv
import matplotlib.pyplot as plt
plt.figure()
file =open("graph.csv","r+")
reader = csv.reader(file)
TS=[]
TIME=[]
ACT_ANGLE=[]
DES_ANGLE=[]
for line in reader:
TS.append(line[12])
TIME.append(line[5])
ACT_ANGLE.append(line[7])
DES_ANGLE.append(line[6])
x=TS
z=ACT_ANGLE
#print x
y=DES_ANGLE
plt.plot(x,y)
plt.xlabel('Time in Sec')
plt.ylabel('Actual angle in degree')
plt.show()
plt.savefig("example.png")