csv module

luca72 lucaberto at libero.it
Fri Aug 24 10:29:05 EDT 2007


Hello at all i have a problem with the csv module, really i don't
undestud the writerows:

if i have to write only one row i do as follow:
def scrivo_csv(self):
        import csv
        q_righe = self.tableWidget.rowCount()
        for row in range(q_righe) :
            e_vuota = self.tableWidget.item(row, 5)
            if e_vuota == None :
                ultima = row
                break
        writerdocs = open("some.csv", "wb")
        scritt = csv.writer(writerdocs, delimiter='|')
        q_colonne = self.tableWidget.columnCount()
        ss = 0
        while ss < row :
            riga = []
            for val in range(q_colonne):
                esiste = self.tableWidget.item(ss, val)
                if esiste == None :
                    luca = ''
                else :
                    luca = str(QtGui.QTableWidgetItem.text(esiste))
                riga.append(luca)
            scritt.writerow(riga)
            ss+=1
This work only with one row in the tablewidget, but if i have more
than one row how i have to proceed?

Thanks for the help

Luca




More information about the Python-list mailing list