Select to view content in your preferred language

Convert Result Object to GDB Table

2519
20
Jump to solution
06-05-2013 10:39 AM
JohnDye
Deactivated User
I have a table being returned from the Network Analyst OD Cost Matrix...

I want to convert the result object to a GDB Table and I tried using this..
ODCM_Table = arcpy.na.Solve(outNALayer) #Solves the Origin-Destination Cost Matrix and produces the ODCM_Table
arcpy.TableToTable_conversion(ODCM_Table, workspace + "\Default.gdb", "ODCM") # Thought this should convert result to GDB Table

But it throws an error:
Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\conversion.py", line 1904, in TableToTable raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Rows: Dataset GPL0 does not exist or is not supported Failed to execute (TableToTable).

I thought maybe the cause of the error was the formatting of the result object being held on the 'ODCM_Table' variable, so I printed it to see what it returns...
print ODCM_Table
GPL0

No problem I can see there.

So how can I convert this result object to an actual table?
Tags (2)
0 Kudos
20 Replies
RhettZufelt
MVP Notable Contributor
John,

I realized that you could not just dump the resultant  featurelayer 'outNALayer' to a table, however, you say you are successfully writing it to a .lyr file. (arcpy.SaveToLayerFile_management(outNALayer, workspace + "\\" + outLayerFile, "RELATIVE"))

a .lyr file can be used in the table to table tool directly.  Would think that if the outLayerFile.lyr had the information to add it to ArcMap, that using it directly in the export would give the results that you are after.


Could be something to do with the nature of a layer file created for a na composite layer not letting you do it, I'm not sure.

Again, I don't have composite layers to examine/test, but curious what "changes" to the layer or outLayerFile.lyr file are made just by adding it to ArcMap?  I was under the impression that arcpy can get the same information from the .lyr file that ArcMap can (however, the sub-layer could be and issue here).

I was only suggesting, that if ArcMap doesn't actually "change" any data/info when you add it to the map, thought you could skip that part.   Would suspect that maybe this is the only way to 'extract' a sublayer from the .lyr, but just thought I'd throw this out there in case (since I can't test).

With my .lyr files (again, just basic datasets, not a composite layer),  I get the same results if I table to table the .lyr file itself, vs, loading that into arcmap and dumping the table out.

R_

Further testing with a "group" layer, and I see that the TableToTable tool has issues and see's it as invalid input......  Thus the need to add to ArcMap..
0 Kudos