I am beginner about arcpy, i has a *.shp file (point), that i will split to few layers based on date in a date_idx50 field (string type).
I use this coding, to process single layer, and this is working :
import os
import arcpy
from arcpy import env
mxd = arcpy.mapping.MapDocument("C:/Arc-Train/forma/training/layout/frame_report_latihan.mxd")
df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]
layer1 = arcpy.mapping.ListLayers(mxd)[3]
q = "date_idx50 = '2010-12-01'"
layer2 = arcpy.MakeFeatureLayer_management(layer1,"2010-12-01",q,"#","FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;id id VISIBLE NONE;lat lat VISIBLE NONE;lon lon VISIBLE NONE;date_idx50 date_idx50 VISIBLE NONE")
arcpy.SaveToLayerFile_management(layer2,layerpath + "2010-12-01.lyr","#")
I need to looping process, so i need each date data in date_idx50 field, will be created as one layer, i try to change coding "q" like this :
import os
from datetime import date
import arcpy
from arcpy import env
mxd = arcpy.mapping.MapDocument("C:/Arc-Train/forma/training/layout/frame_report_latihan.mxd")
df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]
layer1 = arcpy.mapping.ListLayers(mxd)[3]
tanggal = date(2010,12,1)
q = '"' + 'date_idx50' + ' ' + '=' + ' ' + "'" + str(tanggal) + "'" + '"'
layer2 = arcpy.MakeFeatureLayer_management(layer1,"2010-12-01",q,"#","FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;id id VISIBLE NONE;lat lat VISIBLE NONE;lon lon VISIBLE NONE;date_idx50 date_idx50 VISIBLE NONE")
arcpy.SaveToLayerFile_management(layer3,layerpath + "2010-12-01.lyr","#")
But i get Error process in MakeFeatureLayer_management, (just for process 1 layer). So i can't continue to create loop coding.
anyone can help me? or maybe has a new idea?
Thanks