AttributeError:'file'对象没有属性'data'

时间:2016-08-29 12:49:30

标签: python-2.7 csv save

我该如何解决错误:

AttributeError: 'file' object has no attribute 'data'?

在这个程序中:

from PyDAQmx import *
import numpy
from xlwt import Workbook
import csv
# Declaration of variable passed by reference
taskHandle = TaskHandle()
read = int32()
data = numpy.zeros((1000,), dtype=numpy.float64)
#sampling rate
sampleRate = float64(100.0)
samplesPerChan = uInt64(100)

 #specifiy the channels
chan = "Dev1/ai0"
clockSource = "OnboardClock"
print chan
print clockSource

try:
    # DAQmx Configure Code
    DAQmxCreateTask("",byref(taskHandle))
    DAQmxCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,None)
    DAQmxCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,samplesPerChan)

    # DAQmx Start Code
    DAQmxStartTask(taskHandle)

    # DAQmx Read Code
    DAQmxReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByChannel,data,1000,byref(read),None)

    print "Acquired %d points"%read.value
except DAQError as err:
    print "DAQmx Error: %s"%err
finally:
    if taskHandle:
        # DAQmx Stop Code
        DAQmxStopTask(taskHandle)
        DAQmxClearTask(taskHandle)
with open("frequency-domain-data%d.csv", "wb") as ofile:
 ofileWriter = csv.writer(ofile, delimiter='\t') 
#ofileWriter.writerow(data)
for w in data():
ofile.data[i]
ofile.close()
#print data

0 个答案:

没有答案