<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get Error on MakeFeatureLayer_management Processing in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/get-error-on-makefeaturelayer-management/m-p/573610#M44936</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Python format strings can make query (and calculation) expressions even a little easier to read, write, and debug. For example, a way to create your query expression using format strings could be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;whereExpr = "\"%s\" = \'%s\'" % ("date_idx50",tanggal)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Within the SQL expressions, field names may* be enclosed in double quotes and string literals must be in single quotes. In the above expression, the back slashes are to include quotes literally in the resulting string. The "%s" format string has a nice property of converting the corresponding values in the tuple after the "%" operator to a string format, avoiding clouding your code up with a str() function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;*Double quotes around field names may avoid problems with field names that could be SQL keywords, for example, COUNT.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 28 Jan 2012 06:03:20 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2012-01-28T06:03:20Z</dc:date>
    <item>
      <title>Get Error on MakeFeatureLayer_management Processing</title>
      <link>https://community.esri.com/t5/python-questions/get-error-on-makefeaturelayer-management/m-p/573607#M44933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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). &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I use this coding, to process single layer, and this is working :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; mxd = arcpy.mapping.MapDocument("C:/Arc-Train/forma/training/layout/frame_report_latihan.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; layer1 = arcpy.mapping.ListLayers(mxd)[3]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; q = "date_idx50 = '2010-12-01'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; layer2 = arcpy.MakeFeatureLayer_management(layer1,"2010-12-01",q,"#","FID FID VISIBLE NONE;Shape Shape VISIBLE&amp;nbsp;&amp;nbsp; NONE;id id VISIBLE NONE;lat lat VISIBLE NONE;lon lon VISIBLE NONE;date_idx50 date_idx50 VISIBLE NONE")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; arcpy.SaveToLayerFile_management(layer2,layerpath + "2010-12-01.lyr","#")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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 :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; from datetime import date&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; mxd = arcpy.mapping.MapDocument("C:/Arc-Train/forma/training/layout/frame_report_latihan.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; layer1 = arcpy.mapping.ListLayers(mxd)[3]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; tanggal = date(2010,12,1)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; q = '"' + 'date_idx50' + ' ' + '=' + ' ' + "'" + str(tanggal) + "'" + '"'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; 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")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; arcpy.SaveToLayerFile_management(layer3,layerpath + "2010-12-01.lyr","#")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But i get Error process in MakeFeatureLayer_management, (just for process 1 layer). So i can't continue to create loop coding.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;anyone can help me? or maybe has a new idea? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jan 2012 07:27:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-error-on-makefeaturelayer-management/m-p/573607#M44933</guid>
      <dc:creator>FransiskaWidiastuti</dc:creator>
      <dc:date>2012-01-27T07:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: Get Error on MakeFeatureLayer_management Processing</title>
      <link>https://community.esri.com/t5/python-questions/get-error-on-makefeaturelayer-management/m-p/573608#M44934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try using this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;q = "date_idx50 = " + "'" + str(tanggal) + "'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;layer2 = arcpy.MakeFeatureLayer_management(layer1,"2010-12-01",q,"","")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jan 2012 16:08:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-error-on-makefeaturelayer-management/m-p/573608#M44934</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2012-01-27T16:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get Error on MakeFeatureLayer_management Processing</title>
      <link>https://community.esri.com/t5/python-questions/get-error-on-makefeaturelayer-management/m-p/573609#M44935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you..that is working now.&amp;nbsp; ^_^&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jan 2012 03:25:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-error-on-makefeaturelayer-management/m-p/573609#M44935</guid>
      <dc:creator>FransiskaWidiastuti</dc:creator>
      <dc:date>2012-01-28T03:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Get Error on MakeFeatureLayer_management Processing</title>
      <link>https://community.esri.com/t5/python-questions/get-error-on-makefeaturelayer-management/m-p/573610#M44936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Python format strings can make query (and calculation) expressions even a little easier to read, write, and debug. For example, a way to create your query expression using format strings could be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;whereExpr = "\"%s\" = \'%s\'" % ("date_idx50",tanggal)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Within the SQL expressions, field names may* be enclosed in double quotes and string literals must be in single quotes. In the above expression, the back slashes are to include quotes literally in the resulting string. The "%s" format string has a nice property of converting the corresponding values in the tuple after the "%" operator to a string format, avoiding clouding your code up with a str() function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;*Double quotes around field names may avoid problems with field names that could be SQL keywords, for example, COUNT.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jan 2012 06:03:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-error-on-makefeaturelayer-management/m-p/573610#M44936</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2012-01-28T06:03:20Z</dc:date>
    </item>
  </channel>
</rss>

