First you will need an iterator to go through your shape files, there are two methods I employ:
Method One: a folder full of shape files:
import arcpy, sys
InF = sys.argv[1]
arcpy.env.workspace=InF
for fc in arcpy.ListFeatureClasses():
Method Two: a whole tree full of shape files:
import sys, os, arcpy
InFolder = sys.argv[1]
for (path, dirs, files) in os.walk(InFolder):
for ThisFile in files:
fName,fExt = os.path.splitext(ThisFile)
if fExt.upper() == ".SHP":
fc = path + "\\" + ThisFile
Next, decide where your output is going, for this example I'm using the same folder and calling the new shapefile with the old name appended with _WithZ
:
fileName, fileExt = os.path.splitext(fc) # separates file name and extension
outShape = fileName + "_WithZ.shp"
This works for either of the two file iteration methods.
If you already have files that have the output name this may cause problems if overwrite is off so set overwrite to on using arcpy.env arcpy.env.overwriteOutput = True
Then as ChrisW indicated the quickest way to do this is with Make XY Event layer - this is a layer, not a shape file so will have to be copied to such using Copy Features:
# get the existing spatial reference, assuming the X,Y & Z coordinates are in the same system
desc = arcpy.Describe(fc)
spatialRef = desc.spatialReference
# make and export the Event Layer
arcpy.MakeXYEventLayer_management (fc, "POINT_X", "POINT_Y", "Event Layer", spatialRef, "POINT_Z")
arcpy.CopyFeatures_management("Event Layer",outShape)
arcpy.Delete_management("Event Layer") # clear the layer now we're finished with it
There are other ways to make the layer into a shape file; without debating on which one is better or more appropriate in this case using copy features works but feel free to substitute any other method that does essentially the same thing.
That should be enough code to string together a working script to fix the existing problem but it would be better to fix the original script.