处理csv文件

#-------------------------------------------------------------------------------
# Name:        module1
# Purpose:
#
# Author:      maoyongx
#
# Created:     21/01/2015
# Copyright:   (c) maoyongx 2015
# Licence:     
#encoding='utf-8'
#-------------------------------------------------------------------------------
from __future__ import division
import csv
import datetime,time
import sys


exceltotalline=0
fail=0
success=0
starttime=''
endtime=''
a=0
info=[]
infosub=[]
infoerr=[]
infoerrsub=[]
parameter=0.85
def main():
    global exceltotalline
    global fail
    global success
    global starttime
    global endtime
    global a
    global info
    global infosub
    global infoerr
    global infoerrsub


    try:
        #address=raw_input("please input file address :")
        #print address
        address = sys.argv[1]




    #------------------------
        csvfile = file(address, 'rb')
    except:
        if address =='':
            print "address can't null"
            exit()
        else:
            print "please input correct address,example:python csv_read.py C:\\aa.csv"
            exit()
    reader = csv.reader(csvfile)
    #print type(reader)
    for line in reader:
        a=a+1
    csvfile.close()


    #-----------------------
    csvfile = file(address, 'rb')


    reader = csv.reader(csvfile)


    infoerrsub.append("TC Name")
    infoerrsub.append("Start ")
    infoerrsub.append('End Time')
    infoerrsub.append("Pass Rate")
    infoerr.append(infoerrsub)
    #print infoerr,'\n\n'
    infoerrsub=[]




    for line in reader:
        #print type(line)  
        #print line
        if '"total_state"'  in line or  '"1/1"' in line:
            if line[5]!='"1"':
                rate=line[5].replace('"','')


                if float(rate)


 
 

你可能感兴趣的:(脚本,python,Intel)