how can i plot the graph for the below code.I am having matplot library.plot graph for time vs v1 and time vs v2 and in Time1.csv file for tS

import csv


def test1():
    inputCSV = open(r'test.csv', 'rb')
    outputCSV = open(r'test1.csv', 'wb+')
    appendCSV = open(r'test1.csv', 'ab+')
    cr = csv.reader(inputCSV, dialect = 'excel')
    cw = csv.writer(outputCSV, dialect = 'excel')
    ca = csv.writer(appendCSV, dialect = 'excel')
    for row in cr:
        if row or any(row) or any(field.strip() for field in row):
            ca.writerow(row)
    inputCSV.close()
    outputCSV.close()
    appendCSV.close()


def time1():
    inputCSV = open(r'time.csv', 'rb')
    outputCSV = open(r'time1.csv', 'wb+')
    appendCSV = open(r'time1.csv', 'ab+')
    cr = csv.reader(inputCSV, dialect = 'excel')
    cw = csv.writer(outputCSV, dialect = 'excel')
    ca = csv.writer(appendCSV, dialect = 'excel')
    for row in cr:
        if row or any(row) or any(field.strip() for field in row):
            ca.writerow(row)
    inputCSV.close()
    outputCSV.close()
    appendCSV.close()

def fopen():
    f=open("test.csv","w+");
    f1=open("time.csv","w+")
    result = csv.writer(f1,delimiter=',', dialect='excel-tab')
    result_statement1=("HOUR","MIN","SEC","Total_Sec")
    result.writerow(result_statement1)
    f1.close()

    #result = csv.writer(f,delimiter=',')
    result = csv.writer(f,delimiter=',', dialect='excel-tab')
    result_statement=("MODE","Dir","ON_OFF","MODE","DATE","TIME","v1","v2","FLAG")
    result.writerow(result_statement)
    f.close()





import csv
import os
import time
import sys
import string
import math
from operator import mul
from test import test1
from test import time1
from test import fopen


def main():
    pass

if __name__ == '__main__':
    main()
    COUNT=0
    fopen()
    while COUNT<=5:

      time.sleep(3)
      str=("MODE:Track\r\ndir: FWD\r\nOn/OFF:0\r\nMode:1\r\nLocal Date & Time:16/3/2013:.2.30.10\r\nv1:-29.99\r\nv2:-27.63\r\ncount:0\r\n------------\r\n")

      val=str.split(":")
     #print "value is:\n",val
      lines=str.split("\r\n")
     # print  "line statement are :\n",lines
      COUNT=COUNT+1
      print COUNT

      f=open("test.csv","a+");
      test1()

      result = csv.writer(f,delimiter=',', dialect='excel-tab')
      wst=[]
      for line in lines[:-1]:
            parts=line.split(":")
            for p in parts[1:]:
                wst.append(p)
      result.writerow(wst)
      f.close()



      f1=open("time.csv","a+");
      time1()
      result = csv.writer(f1,delimiter=',')
      str1=wst[5]
      #print "str1 is :\n",str1
      sp=str1.split(".")
      del sp[0]
     # print "sp is :\n",sp
      y0=int(sp[0])
      y1=int(sp[1])
      y2=int(sp[2])
      y=[y0,y1,y2]
      x=[3600,60,1]
      z =map(mul,x,y)
      y.insert(3,sum(z))
      result.writerow(y)
      f1.close()




      print "wst:\n",wst
      print "value of y is :\n",y



f.close()

You are trying to use simultanously on single file in two modes, which does not make any sense:

inputCSV = open(r'test.csv', 'rb')
outputCSV = open(r'test1.csv', 'wb+')
appendCSV = open(r'test1.csv', 'ab+')
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.