[wxPython] Saving data from wxListCtrl

Desire to save data to file.

···

_________________________________

Presently using wxListCtrl, connecting to sql database and reading data
into "row" using:

            row = self.curs.fetchall()

Insert data into columns as follows:

            while cnt < rcnt:
                #print row[cnt]
                rrow = row[cnt]
                self.out.InsertStringItem(cnt, str(row[cnt]))
                for x in range(0,nrcol,1):
                    self.out.SetStringItem(cnt,x,str(rrow[x]))
                cnt = cnt+1

Presently saving to file as follows:

            trec = len(self.row)
            f=open(self.dirname+'\\'+self.filename,"w")
            for rec in range(trec):
                f.write(str(self.row[rec])+"\n")
            f.close()
_____________________________________________
The problem with the above save is that
  the record is enclosed in '(', ')'
  number fields have a 'L' tacked onto the end

I am saving to a file so that I may put the data into a spreadsheet and
generate a report.

Any suggestion is appreciated.

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

This is because your "row" is a list of lists.
row[0] returns the first row as a list, hence the brackets around the result.

Do instead:
rows = cursor.fetchall()
for row in rows:
  for column in row:
    print str(column)

Horst

···

On Fri, 27 Sep 2002 00:15, DJ Webre wrote:

The problem with the above save is that
  the record is enclosed in '(', ')'
  number fields have a 'L' tacked onto the end

Did you borrow Guido's time machine? :wink:

···

At 08:01 2002-09-16 +1000, Horst Herb wrote:

On Fri, 27 Sep 2002 00:15, DJ Webre wrote:

--
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se