Este es un ejemplo de la técnica que mencioné en mi comentario a tu pregunta. Leer un CSV y rellenar una clase de característica con sus valores puede ser fácil. El script asume que el Latitud es la primera columna y Longitud es la segunda columna. Puede ajustar el sistema de coordenadas en el código a algo distinto de WGS84, ajustar los tipos de campo, etc.
# Author: John K. Tran
# Contact: jtran20@masonlive.gmu.edu
import arcpy
import os
import csv
print "arcpy imported"
"""
Input CSV can look like:
Lat,Lon,First Name,Last Name
12.34,56.78,Joe,Smith
0.98,7.65,Jane,Doe
65.43,43.21,Bob,Sagat
Make sure 'Lat' and 'Lon' fields are the 1st and 2nd column in the CSV respectively.
"""
incsv = r"C:\Users\MyName\Desktop\My Docs\Sample Data\SampleCSV.csv" # Change this to the path of your CSV file.
outfc = r"C:\Users\MyName\Desktop\My Docs\Sample Data\SampleGDB.gdb\SampleFC" # Change this to the path of your output FC.
spatialref = arcpy.SpatialReference(4326) # Create the spatial reference object as WGS84. Can modify if desired.
if not arcpy.Exists(outfc): # Create the output feature class if needed.
arcpy.CreateFeatureclass_management(os.path.dirname(outfc), os.path.basename(outfc), "POINT", None, None, None, spatialref)
csv.register_dialect("xls", delimiter=",", lineterminator="\n") # Register the dialect for native CSV syntax in Microsoft Excel.
f = open(incsv, "r")
reader = csv.reader(f, dialect = "xls")
headers = reader.next() # Read the first line as the header names.
for header in headers[2:]: # Add fields for remaining columns if needed. Default is TEXT field.
arcpy.AddField_management(outfc, header, "TEXT")
cursor = arcpy.da.InsertCursor(outfc, ['SHAPE@XY'] + headers[2:]) # Create InsertCursor.
count = 0
for row in reader:
if count % 1000 == 0:
print "processing row {0}".format(count)
Ycoord = row[0] # Make sure 'Lat' is in the 1st column.
Xcoord = row[1] # Make sure 'Lon' is in the 2nd column.
newrow = [(float(Xcoord), float(Ycoord))] + row[2:]
cursor.insertRow(newrow) # Insert point in FC for each row in CSV.
count += 1
del cursor
f.close()
Y un ejemplo de un CSV que se puede leer es:
Lat,Lon,FirstName,LastName,Tone,Magnitude
26.61,-81.49,John,Smith,Dark,6.0
26.68,-81.47,Jim,Jones,Light,9.0
20.01,-155.87,Steve,Bruin,Medium,3.9
25.43,-80.45,Bob,Johnson,Dark,2.75
26.05,-80.11,Bill,Mayer,Light,26.6
100.000 registros CSV me han llevado entre 3 y 5 segundos.