I know that there is a command called LEN() and if used on a dataset will tell you how many records long the dataset is.
My question is, is there a similar command for determining the number of columns?
I am using a stored proceedure and depending on the variables sent across determines the number of columns returned. I want to be able to used this in an if statement.
Thanks and have a great day.
If you’re needing the number of columns in a “standard” dataset (vs. a pyDataSet), you can use the following:
columnCount = datasetname.getColumnCount()
columnCount2 = datasetname.columnCount
Here are some other functions you might find useful:
rowCount = datasetname.getRowCount()
rowCount2 = datasetname.rowCount
columnNames = datasetname.getColumnNames()
columnName = datasetname.getColumnName(columnIndex)
columnIndex = datasetname.getColumnIndex("ColumnName")
columnTypes = datasetname.columnTypes
columnType0 = columnTypes[0]
columnList = datasetname.getColumnAsList(columnIndex)
columnList2 = datasetname.data[columnIndex]
value = datasetname.getValueAt(rowIndex, columnIndex)
value2 = datasetname.getValueAt(rowIndex, "ColumnName")
value3 = datasetname.data[columnIndex][rowIndex] #Note index order
value4 = datasetname.getData()[columnIndex][rowIndex] #Note index order
datasetname.setValueAt(rowIndex, columnIndex, newValue)
datastname.data[columnIndex][rowIndex] = newValue #Note index order
dsContainsNulls = datasetname.datasetContainsNulls()
colContainsNulls = datasetname.columnContainsNulls(columnIndex)
dsXML = datasetname.getAsXML()
dsXML2 = datasetname.asXML
print datasetname.__class__.__dict__
If you want the width of a pyDataSet, you can use this:
columnCount3 = len(pydatasetname[0])