import sys
import string
import os
import arcgisscripting
gp = arcgisscripting.create(9.3)
# Set a default workspace
gp.workspace = "C:\working\Y2010\Franks\Plant"
# Set a toolbox
gp.toolbox = "management"
ScriptNm = sys.argv[0]
ScriptSub = os.path.basename(ScriptNm)
try:
#Add fields
gp.addfield ("\\FT_testing.gdb\FT_2010_P000\FT10_P180_Plant_test", "Depth_ft", "float", "5", "2")
gp.addfield ("\\FT_testing.gdb\FT_2010_P000\FT10_P180_Plant_test", "Script", "text", "15")
except:
# If an error occurs when running Addfield, print out the error message.
print gp.GetMessages(2)
try:
############################
# CALCULATIONS
gp.CalculateField_management("\\FT_testing.gdb\FT_2010_P000\FT10_P180_Plant_test", "Depth_ft", "[ftbathy] * 3.2808 ", "VB")
#This line is the problem RIGHT HERE ???
gp.CalculateField_management("\\FT_testing.gdb\FT_ 2010_P000\FT10_P180_Plant_test", "Script", 'ScriptSub', "VB", "")
except:
# If an error occurs when running Addfield, print out the error message.
print gp.GetMessages(2)
try:
print ScriptNm
print ScriptSub
except:
# If an error occurs when running Addfield, print out the error message.
print gp.GetMessages(2)
'"'+ScriptSub+'"'
#-----------------------------------------------------------------------------------------------------------
# File Name Insert
# Script written by Rocky Rudolph - April, 2006 - Channel Islands National Park, California
# Purpose: for creating a field called "FILENAME" and attaching the filename of the shapefile to each entry
# in the attribute table. Use with as many shapefiles within a specified directory.
# Useful when picking apart shapefile entries and combining into a separate file to
# maintain a breadcrumb trail of the original shapefile name.
#
# Run file within a directory containing all the shapfiles needing modification
# Make sure FILENAME field doesn't already exist in any of the shapefiles
#
#-----------------------------------------------------------------------------------------------------------
#import relevant modules, create geoprocessing dispatch object
import win32com.client, sys, string, os
gp = win32com.client.Dispatch("esriGeoprocessing.gpDispatch.1")
# Remember to change this to wherever your shapefiles are stored
gp.workspace = "C:\\working\\Y2010\\Franks\\Plant\\FT_testing.gdb\\testing"
try:
fcs = gp.ListFeatureClasses("*", "all")
fcs.reset()
fc = fcs.Next()
Script = sys.argv[0]
ScriptSub = os.path.basename(Script)
print Script
print ScriptSub
while fc:
# Create the new field
gp.AddField_management (fc, "FILENAME", "text", "", "", "50")
# Apply the filename to all entries
gp.CalculateField_management (fc, "FILENAME", '"' + ScriptSub + '"')
fc = fcs.Next()
except:
print gp.GetMessages ()