table = arcpy.GetParameter(0) result = table optable = result.getOutput(0)
See the help topic Setting script tool parameters. It appears you want a derived output parameter, so pay particular attention to the write-ups about derived output parameters.
import arcpy inTable = arcpy.GetParameter(0) arcpy.SetParameter(1, inTable)
table = arcpy.GetParameter(0) result = table optable = result.getOutput(0)
result = arcpy.TableToTable_conversion('inputTable','in_memory','outputTable) optable = result.getOutput(0)
I'm not sure this is exactly what you want to do, but try this code:import arcpy inTable = arcpy.GetParameter(0) arcpy.SetParameter(1, inTable)
Maybe I'm confused why you're casting something to something else? If you want to inspect the attributes of the featureclass you can do it the same if its features or a table (recordset). I assume you'll be using a search cursor to loop through the attributes?
And can you post a link to the doc where this isn't working? If you're using:table = arcpy.GetParameter(0) result = table optable = result.getOutput(0)
Result should be the result of a GP operation....result = arcpy.TableToTable_conversion('inputTable','in_memory','outputTable) optable = result.getOutput(0)
Ok, I am working with arcserver, and my only goal is to be able to do whatever I want with a table....preferably by using a search cursor to feed it into lists, modify the values, and then output a recordset which can be displayed in arcserver.
I will play with what you've put up for a bit a post again. I really do appreciate the help.
import arcpy inTable = arcpy.GetParameterAsText(0) SearchRows = arcpy.SearchCursor(inTable) outTable = r'in_memory/OuTable' outRows = arcpy.InsertCursor(outTable) for row in SearchRows: value1 = row.NAME value2 = row.TYPE value3 = row.SUPERFIELD singleOutRow = outRows.newRow() singleOutRow.outNAME = value1 singleOutRow.outTYPE = value2 singleOutRow.outSUPERFIELD = value3 outRows.insertRow(singleOutRow) arcpy.SetParameter(1, outTable)
Right - I wouldn't worry about the conversion then...just use the cursor right off the input features. Do you thing, then write out the new table. Here's some untested code off the top of my headimport arcpy inTable = arcpy.GetParameterAsText(0) SearchRows = arcpy.SearchCursor(inTable) outTable = r'in_memory/OuTable' outRows = arcpy.InsertCursor(outTable) for row in SearchRows: value1 = row.NAME value2 = row.TYPE value3 = row.SUPERFIELD singleOutRow = outRows.newRow() singleOutRow.outNAME = value1 singleOutRow.outTYPE = value2 singleOutRow.outSUPERFIELD = value3 outRows.insertRow(singleOutRow) arcpy.SetParameter(1, outTable)