def listFields(inputTable, wildCard = "", fieldType = ""): """Lists fields (and selected properties) for inputTable""" fieldList = arcpy.ListFields(inputTable, wildCard, fieldType) #FORMATTING INFO: NAME = 50 spaces, TYPE = 15 spaces, LENGTH = 15 spaces, SCALE = 15 spaces, PRECISION = 15 spaces print "NAME " + "TYPE " + "LENGTH " + "SCALE " + "PRECISION " print "-" * 100 for field in fieldList: print str(field.name)[0:50] + " "*(50-len(field.name)) \ + str(field.type)[0:15] + " "*(15-len(str(field.type))) \ + str(field.length)[0:15] + " "*(15-len(str(field.length))) \ + str(field.scale)[0:15] + " "*(15-len(str(field.scale))) \ + str(field.precision)[0:15] + " "*(15-len(str(field.precision))) def listRecs(inputTable, numberOfRecordsToList = 25, whereClause = ""): """Lists field names and corresponding field values in inputTable""" fieldNamesList = [f.name for f in arcpy.ListFields(inputTable)] rowCount = 1 recordCount = int(arcpy.GetCount_management(inputTable).getOutput(0)) if int(numberOfRecordsToList) > recordCount: numberOfRecordsToList = recordCount searchRows = arcpy.da.SearchCursor(inputTable, ["*"], whereClause) searchRow = searchRows.next() while rowCount <= int(numberOfRecordsToList): print "RECORD #" + str(rowCount) print "-" * 50 for fieldName in fieldNamesList: try: print fieldName + ": " + str(searchRow[fieldNamesList.index(fieldName)]) except: print fieldName + ": !?!" print "" print "" rowCount = rowCount + 1 searchRow = searchRows.next() del searchRow, searchRows print "" print "" print "LISTED " + str(numberOfRecordsToList) + " RECORDS"
Beautiful! I built something similar (but definitely not as fancy) a while back... like your arcapi, my lmpy basically made python/arcpy more of a command prompt sort of interface (for those that like that sort of thing).Hope to contribute to your project sometime... if I ever have time again to do that sort of thing :rolleyes:Good job Filip and Caleb!
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.