Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Please can you help, I am struggling how to create a multidimensional array from a loop. I am looping through rows in a data table and want to pass these to an array. Thanks Jay

from Spotfire.Dxp.Data import DataValueCursor
from System import  DateTime, TimeSpan, DayOfWeek
from datetime import date
import time


#define ID
idcursor=DataValueCursor.Create[str](table.Columns["ID"])

#define actual date
actualcursor=DataValueCursor.Create[str](table.Columns["ActualDate"])

#define duration
durationcursor=DataValueCursor.Create[int](table.Columns["Duration"])

#define Start, # of Months and # of days
startcursor=DataValueCursor.Create[int](table.Columns["Start Months"])
monthcursor=DataValueCursor.Create[int](table.Columns["Number of Months"])
daycursor=DataValueCursor.Create[int](table.Columns["Number Of Days"])

#define Min and Max Dates
mincursor=DataValueCursor.Create[str](table.Columns["Min Date"])
maxcursor=DataValueCursor.Create[str](table.Columns["Max Date"])

myPanel = Document.ActivePageReference.FilterPanel
idxSet =    myPanel.FilteringSchemeReference.FilteringSelectionReference.GetSelection(table).AsIndexSet()

bar = []
for row in table.GetRows(idxSet,idcursor,durationcursor,actualcursor,startcursor,monthcursor,daycursor):
#I would like this line to populate the array 
 bar.append(idcursor.CurrentValue)
share|improve this question
    
what are you getting in bar? –  TehTris May 8 at 18:07
    
Thanks I only get the idcursor values i.e. ['1', '2', '3']. I would like to see the other cursor values that are in the loop i.e durationcursor,actualcursor,startcursor,monthcursor,daycursor –  Jay W May 8 at 18:11
    
you presumably only add the idcursor value because that's all you append to bar. Have you tried appending the values of the other things in list form, like bar.append([idcursor,durationcursor,actualcursor]) and so on? –  Dannnno May 8 at 18:18
    
yeah Danno, I get a error if I add say another cursor in like so bar.append(idcursor.CurrentValue,durationcursor.CurrentValue) This is the error Microsoft.Scripting.ArgumentTypeException: append() takes exactly 1 argument (2 given) –  Jay W May 8 at 18:25
    
Hi for row in table.GetRows(idxSet,idcursor,durationcursor,actualcursor,startcursor,monthcurso‌​r,daycursor): brandList.append(idcursor.CurrentValue) durationList.append(durationcursor.CurrentValue) actualList.append(actualcursor.CurrentValue) startList.append(startcursor.CurrentValue) monthList.append(startcursor.CurrentValue) dayList.append(daycursor.CurrentValue) –  Jay W May 12 at 13:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.