I want to built a ResultsTable by adding a set of column to the
ResultsTable. my code is: for i in objectIndicesSet: tempAreaList = [objectAreas[j] for j in range(len(objectAreas)) if objectIndices[j] == i] print tempAreaList # here is where I wodl like to reset the Counter for k in tempAreaList: rtRearranged.incrementCounter() rtRearranged.addValue("Object "+str(i), k) where I am adding the list tempAreaList to a column labeled "Object #" This works, except that I cannot find a way to reset the Counter, so when the second column is written (ie when "Object #" changes, and a new column is automatically created), the counter is still on the last row and the next column starts there. What I really want to do is have the new column start at the first row again, as I indicate with a comment above. Is this possible, or do I have to create all of the area lists, and the write tehm out one row at a time? Thanks in advance. --aryeh -- Aryeh Weiss Faculty of Engineering Bar Ilan University Ramat Gan 52900 Israel Ph: 972-3-5317638 FAX: 972-3-7384051 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
> On Nov 10, 2018, at 4:15 PM, Aryeh Weiss <[hidden email]> wrote:
> > I want to built a ResultsTable by adding a set of column to the ResultsTable. > > my code is: > > for i in objectIndicesSet: > tempAreaList = [objectAreas[j] for j in range(len(objectAreas)) if objectIndices[j] == i] > print tempAreaList > # here is where I wodl like to reset the Counter > for k in tempAreaList: > rtRearranged.incrementCounter() > rtRearranged.addValue("Object "+str(i), k) > > where I am adding the list tempAreaList to a column labeled "Object #" > > This works, except that I cannot find a way to reset the Counter, so when the second column is written (ie when "Object #" changes, and a new column is automatically created), the counter is still on the last row and the next column starts there. What I really want to do is have the new column start at the first row again, as I indicate with a comment above. > > Is this possible, or do I have to create all of the area lists, and the write tehm out one row at a time? Use rt.setValue(column,rowIndex,value) instead of rt.addValue(column,value). -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On 12/11/2018 22:02, Wayne Rasband wrote:
>> On Nov 10, 2018, at 4:15 PM, Aryeh Weiss <[hidden email]> wrote: >> >> I want to built a ResultsTable by adding a set of column to the ResultsTable. >> >> my code is: >> >> for i in objectIndicesSet: >> tempAreaList = [objectAreas[j] for j in range(len(objectAreas)) if objectIndices[j] == i] >> print tempAreaList >> # here is where I wodl like to reset the Counter >> for k in tempAreaList: >> rtRearranged.incrementCounter() >> rtRearranged.addValue("Object "+str(i), k) >> >> where I am adding the list tempAreaList to a column labeled "Object #" >> >> This works, except that I cannot find a way to reset the Counter, so when the second column is written (ie when "Object #" changes, and a new column is automatically created), the counter is still on the last row and the next column starts there. What I really want to do is have the new column start at the first row again, as I indicate with a comment above. >> >> Is this possible, or do I have to create all of the area lists, and the write tehm out one row at a time? > Use rt.setValue(column,rowIndex,value) instead of rt.addValue(column,value). > > -wayne > -- Thank you, Wayne. Works as advertised. I had not realized that the setValue command will also automatically add a column if it does not exist, same as the addValue command. Best regards --aryeh -- Aryeh Weiss Faculty of Engineering Bar Ilan University Ramat Gan 52900 Israel Ph: 972-3-5317638 FAX: 972-3-7384051 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |