def exportData(self): data = [["id", "amount"]] workplaceClause = '' if self.ui.comboBox_workplace.currentIndex() <= 0 else 'and ist_arp_id = %s' % self.getPKForCombobox(self.ui.comboBox_workplace, 'arp_id') query = QtSql.QSqlQuery() query.prepare("""select ist_artikel_id, ist_anzahl from initialer_stand where 1=1 and ist_periode_id = %s %s""" % (self.getCurrentPeriodId(), workplaceClause)) query.exec_() while query.next(): id_, amount = query.value(0).toInt()[0], query.value(1).toInt()[0] data.append([id_, amount]) filename = QtGui.QFileDialog.getSaveFileName(self, 'Datei speichern', '', 'CSV Files (*.csv)') with open(filename, 'wb') as f: writer = UnicodeWriter(f, delimiter="\t") writer.writerows(data)
def exportData(self): filename = QtGui.QFileDialog.getSaveFileName(self, 'Datei speichern', '', 'CSV Files (*.csv)') with open(filename, 'wb') as f: writer = UnicodeWriter(f) writer.writerows(self._data)