XYZ to GRID in Python - performance

Discussion created by RendyO on Jan 29, 2013
Latest reply on Feb 4, 2013 by rafaelr
I have really a lot of zip files which contains *.xyz files and my job is to convert these xyz files to the GRID/DEM.
I want to use Python and the ArcPy. In the first step, I will extract xyz file, go through these file line by line and I'll add the "points" (lines, one by one) to the POINT feature class using the Insert Cursor (I am using 10.0 version of desktop).
In second step I will convert this point feature class to GRID or terrain model... in Spatial Analyst... but what do you thing about first Python step? It will take a really long time. Is there any way to do it differently?? Faster??
Here is sample of my Python script:

import zipfile
import os
import arcpy

dirPath = "C:/Workspace/Data/tmp/tmpzip/"
outputFileGdb = "C:/Workspace/Data/tmp/test.gdb/"

if (not arcpy.Exists(outputFileGdb + "lidarPoints")):
    arcpy.CreateFeatureclass_management(outputFileGdb, "lidarPoints", "POINT", "", "DISABLED", "ENABLED")

fileInDirList = os.listdir(dirPath)
for file in fileInDirList:
 if file.endswith(".zip"):
  z = zipfile.ZipFile(dirPath + file, "r")
  for filename in z.namelist():
   if filename.endswith(".xyz"):
    print filename
    f =, 'r')
    content =
    lines = content.splitlines(True)
    for line in lines:
      line = line.strip()
      point = line.split(' ')
      esriPoint = arcpy.Point()
      esriPoint.X = point[0]
      esriPoint.Y = point[1]
      esriPoint.Z = point[2]
      cur = arcpy.InsertCursor(outputFileGdb + "lidarPoints")
      row = cur.newRow()
      row.shape = esriPoint
      del cur, row
     except Exception as e:
      print e

Thanks for help and ideas.

Czech Republic