import arcpy import mycount table = "G:\School\Personal Drive\Fall2014\Python\Excercises\Exercise12\streets.shp" print mycount.countstringfields(table)
import mycount table = "C:/Python/Data/Exercise12/streets.shp" mycount.countstringfields(table)
import arcpy from arcpy import env env.workspace = "C:/Users/amhill2604/Desktop/MyExcercises/MyEx12" import mycount print(mycount.countstringfields("streets.shp"))
"""Challenge_1/Part_2:Script where you call the other script called mycount.py """ import sys sys.path.append(r"P:/Python/Python_Textbook_Challenges/Chapters/ch12") import mycount streetsLayer = arcpy.mapping.Layer("streets") numberOfFieldsTypeString = mycount.countstringfields(streetsLayer) del streetsLayer print numberOfFieldsTypeString #Runs but gives a ValueError: Layer is an invalid data source.
import arcpy import mycount table = mycount.countstringfields( "C;/EsriPress/Python/Data/Exercise12/streets.shp") print table
# Name: David Espinola #Date: April 21, 2019 #Description: Challenge 1- Create a custom function called countstringfields that determines the number of fileds of type string in an input feature class #Create this function in a seperate script(for example,mycount.py) that you call from another script(for example,callingscript.py). You can use the streets.shp # feature class in the Exercise12 folder. import arcpy import mycount #import function arcpy.env.workspace = "C:/GEO6533/Python/Data/Exercise12" #set workspace num_strings = mycount.countstringfields( "streets.shp" ) #use function to count number of string fields in streets feature class and save into a variable num_strings print(num_strings) #print value in num_strings