Trouble exporting from plot as csv

74 views
Skip to first unread message

Kevin Brockman

unread,
Aug 16, 2016, 11:17:04 AM8/16/16
to pyqtgraph
Hello, I am attempting to acquire data from the plot generated by this code, but when I attempt to export it via the right click menu I get the following error:

>>> Traceback (most recent call last):
  File "C:\Users\KevinBrockman\AppData\Local\Continuum\Anaconda2\lib\site-packages\pyqtgraph\exporters\Exporter.py", line 72, in fileSaveFinished
    self.export(fileName=fileName, **self.fileDialog.opts)
  File "C:\Users\KevinBrockman\AppData\Local\Continuum\Anaconda2\lib\site-packages\pyqtgraph\exporters\CSVExporter.py", line 48, in export
    numRows = reduce(max, [len(d[0]) for d in data])
TypeError: object of type 'NoneType' has no len()

If anyone could help me get the export working it would be greatly appreciated.

from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
import serial


app = QtGui.QApplication([])

p = pg.plot()
p.setWindowTitle('live plot from serial')
curve = p.plot()

data = [0]
raw=serial.Serial(8,115200)
#raw.open()

def update():
    global curve, data
    line = raw.readline()
    data.append(float(line))
    xdata = np.array(data, dtype='float64')
    curve.setData(xdata)
    app.processEvents()

timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(0)

if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()



Reply all
Reply to author
Forward
0 new messages