title: writing a QTableWidget to a .csv or .xls
body: <p>Is it possible to write the contents of a QTableWidget to a csv?  I found a question about writing to an .xls using xlwt, but can't seem to get it to work using my code.  </p>
  
  <pre><code>def saveFile(self):
      filename = unicode(QtGui.QFileDialog.getSaveFileName(self, 'Save File', '', ".xls(*.xls)"))    
      wbk = xlwt.Workbook()
      self.sheet = wbk.add_sheet("sheet")
      self.write()
      wbk.save(filename)    
  
  
  def write(self):
      for col in range (self.coordinates.columnCount()):
          for row in range(self.coordinates.rowCount()):
              text=str(self.coordinates.item(row,col).text())
              self.sheet.write(row,col,text)
  </code></pre>
  
  <p>I get the following error: </p>
  
  <pre><code>  File "C:\Users\Tory\Desktop\DIDSON.py", line 186, in saveFile
      self.write()
    File "C:\Users\Tory\Desktop\DIDSON.py", line 192, in write
      text=str(self.coordinates.item(row,col).text())
  AttributeError: 'NoneType' object has no attribute 'text'
  </code></pre>
  
  <p>Why is this?  self.coordinates is a QTableWidget.  I was able to get the items themselves to save successfully to a worksheet, although I'd still like to save as a .csv... </p>