From:
f = open(someData, ‘rb’)
reader = csv.reader(f)
self.headers = reader.next()
print self.headers
I’d like to transfer that list set to the listmix GetColumn.
I read somewhere in this group to improvise:
item = list.GetColumn(col)
item.SetText(newtext)
list.SetColumn(col, item)
I can’t find any working examples of this.
I’ve attached a sample werner helped me on in a previous post.
Any help would be great!
From:
f = open(someData, 'rb')
reader = csv.reader(f)
self.headers = reader.next()
print self.headers
I'd like to transfer that list set to the listmix GetColumn.
I read somewhere in this group to improvise:
item = list.GetColumn(col)
item.SetText(newtext)
list.SetColumn(col, item)
I can't find any working examples of this.
If you use GetColumn/SetColumn you might run into problems if your current csv has more columns then the last one.
I've attached a sample werner helped me on in a previous post.
Any help would be great!
An alternative would be to take the code you currently have in createAndLayout in relation to the listctrl and split it into:
method 'createList' which receives a list of headers
if list already exists use - lc.ClearAll()
otherwise create it
create the columns using the headers passed in
method 'loadList' which loads the items to the list (see createAndLayout and reloadList)
Then call the first method in createAndLayout with a dummy header list and call both methods from your method which reads the CSV.
…
I would have something like:
self.headers = [‘col1headertext’, ‘col2headertext’]
for this to work you woulc have to have two elements per column, not
really needed no.
colno = 0
for head in self.headers:
self.InsertColumn(colno, head)
colno += 1
Something similar as was in ‘reloadList’ without the deleting of the
items as that is already done.
Werner
···
Hi George,
On 12/10/2013 18:29, George McCown wrote:
On the dummy function, I set up a clear headers list.
I'm using self.headers = []
Then on the reloadList function I can use:
for key, col in self.headers: <-- too many values
to unpack.
self.InsertColumn(0, col)
Like it's done for the SetStringItem method.
I know I'm missing your loadlist method point.
Can you explain again?