<?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 populating a Python List and Queue.Empty error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/populating-a-python-list-and-queue-empty-error/m-p/749876#M57924</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am working on a project where I simply want&amp;nbsp; to create maps of the FHWA Functional Classifications for all the roads in a county.&amp;nbsp; The field name in the roads layer is FUNC.&amp;nbsp; I created a Python List with this name (func), and want to populate it with the functional class values.&amp;nbsp;&amp;nbsp; I keep getting Queue.Empty messages every time I run it.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am a relative newbie at Python, and while I can intuitively get the flow involved--create list, go through rows in table, add values to the list--I don't know what code I'd use to fix this.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a gut feeling I might have to use GetValue to populate the List with the Functional Classification values in order for the script to really work, but I don't know how I'd write it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Script results and Error message below, Script attached. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dan B&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;*************************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SONOMA COUNTY FUNCTIONAL CLASSES and SEGMENTS&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Map Extent of Data Frame is: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;XMin: 6114361.750469, YMin: 1685797.745094, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;XMax: 6477131.750469, YMax: 2180587.745094&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer Name: SONOMA COUNTY STREETS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Longname: SONOMA COUNTY STREETS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;StreetLayer name is: SONOMA COUNTY STREETS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Processing text elements...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Export Functional Class = 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ARCPY ERRORS:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PYTHON ERRORS:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback Info:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Users\Owner\Desktop\GEOG 375\FINAL PROJECT\Brenner_FINAL_TEMPLATE_2_NJ_Coding.py", line 138, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ExportToPDF(mxd, mappath + 'Map ' + str(func_value) + '.pdf')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error Info:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;class 'Queue.Empty'&amp;gt;:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 May 2013 05:12:56 GMT</pubDate>
    <dc:creator>DanielBrenner</dc:creator>
    <dc:date>2013-05-06T05:12:56Z</dc:date>
    <item>
      <title>populating a Python List and Queue.Empty error</title>
      <link>https://community.esri.com/t5/python-questions/populating-a-python-list-and-queue-empty-error/m-p/749876#M57924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am working on a project where I simply want&amp;nbsp; to create maps of the FHWA Functional Classifications for all the roads in a county.&amp;nbsp; The field name in the roads layer is FUNC.&amp;nbsp; I created a Python List with this name (func), and want to populate it with the functional class values.&amp;nbsp;&amp;nbsp; I keep getting Queue.Empty messages every time I run it.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am a relative newbie at Python, and while I can intuitively get the flow involved--create list, go through rows in table, add values to the list--I don't know what code I'd use to fix this.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a gut feeling I might have to use GetValue to populate the List with the Functional Classification values in order for the script to really work, but I don't know how I'd write it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Script results and Error message below, Script attached. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dan B&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;*************************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SONOMA COUNTY FUNCTIONAL CLASSES and SEGMENTS&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Map Extent of Data Frame is: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;XMin: 6114361.750469, YMin: 1685797.745094, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;XMax: 6477131.750469, YMax: 2180587.745094&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer Name: SONOMA COUNTY STREETS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Longname: SONOMA COUNTY STREETS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;StreetLayer name is: SONOMA COUNTY STREETS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Processing text elements...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Export Functional Class = 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ARCPY ERRORS:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PYTHON ERRORS:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback Info:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Users\Owner\Desktop\GEOG 375\FINAL PROJECT\Brenner_FINAL_TEMPLATE_2_NJ_Coding.py", line 138, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ExportToPDF(mxd, mappath + 'Map ' + str(func_value) + '.pdf')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error Info:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;class 'Queue.Empty'&amp;gt;:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 May 2013 05:12:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/populating-a-python-list-and-queue-empty-error/m-p/749876#M57924</guid>
      <dc:creator>DanielBrenner</dc:creator>
      <dc:date>2013-05-06T05:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: populating a Python List and Queue.Empty error</title>
      <link>https://community.esri.com/t5/python-questions/populating-a-python-list-and-queue-empty-error/m-p/749877#M57925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To start, you should include your code in the post using the &amp;lt;square bracket&amp;gt;CODE&amp;lt;square bracket&amp;gt; tags&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;accessable in the # formating button. to wit:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; func_list = []&amp;nbsp; # Creates an empty Python List&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; srows = arcpy.SearchCursor(StreetLayer)&amp;nbsp;&amp;nbsp; # Create a search cursor on the function class feature class


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for srow in srows:&amp;nbsp;&amp;nbsp; # loop over the rows of the functional class layer

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if srow.FUNC not in func_list:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; func_list.append(srow.FUNC)&amp;nbsp; # adds unique FUNC values to the list


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for func_value in func_list:

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query = '"FUNC" = ' + str(func_value)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; StreetLayer.definitionQuery = query&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The list building looks okay&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but you then run through the list, building stings and assigning them to 'query'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but you don't do anything with any except the last.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The StreetLayer.definitionQuery = query assignment is outside the loop&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;so only the last func_value is used.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In any event, the query clause syntax looks funky.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"\"FUNC\" = '%s'" % (func_value)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You need double quotes around the field, and single quotes around the func_value string&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and some sort of quotes around the whole string (to assign it to the variable).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thus, you either wrap it all in double quotes, and escape the double quotes on the field&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or wrap it all in single quotes and escape the single quotes on the value string,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or futz around with tripple quotes, which is a headache.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There may be other issues, but start with these.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try printing some of the values you make and use inside the script, to make sure you are passing what you you expect.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:51:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/populating-a-python-list-and-queue-empty-error/m-p/749877#M57925</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2021-12-12T07:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: populating a Python List and Queue.Empty error</title>
      <link>https://community.esri.com/t5/python-questions/populating-a-python-list-and-queue-empty-error/m-p/749878#M57926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you big time for reaching out to me.&amp;nbsp; I do appreciate it. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did consult with my Professor on the issue and I had to clarify for him that the values in the FUNC field are in Number format and not Text.&amp;nbsp; (They are Short type with a field width of 3.&amp;nbsp; Would the fact they are Short and not Double or? have something to do with my problems?)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Given that they are in number format, he instructed me to use the query statement that you will see on line 72.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, even after doing this, and even bringing in a streets layer with a smaller amount of segments, I am STILL getting the same error message.&amp;nbsp; I am a newbie at Python, but at the same time something is not making it into the "Queue" with&amp;nbsp; the 'for..." loops.&amp;nbsp; Is it because the funct_values aren't getting stored somewhere?&amp;nbsp; Are they even being selected?&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dan Brenner&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 May 2013 06:06:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/populating-a-python-list-and-queue-empty-error/m-p/749878#M57926</guid>
      <dc:creator>DanielBrenner</dc:creator>
      <dc:date>2013-05-09T06:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: populating a Python List and Queue.Empty error</title>
      <link>https://community.esri.com/t5/python-questions/populating-a-python-list-and-queue-empty-error/m-p/749879#M57927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Python execution is goverened by indentation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;your for srow in srows: loop is all twisted up.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My impression is that you want to export a pdf for each setting of the StreetLayer.definitionQuery.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thus, you should &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. make your tElements list&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. open the cursor, make your funct_list list, and close the cursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. start the for funct_value in funct_list:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; 3a. set the query string and apply it to StreetLayer.definitionQuery&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; 3b. set the text elements&amp;nbsp; ( run through the tElements list you made at the start)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; 3c. check for an existing pdf, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; 3d. make the new PDF&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; 3e. start the step three loop over for the next funct_value &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;also...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my experiance, you have to have the correct double and single quotes INSIDE the string you pass as the query.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The format&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'"FUNC" = ' + str(funct_value)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;does not do that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;funct_value = 99999
query = '"FUNC" = ' + str(funct_value)
print query&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;it prints:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "FUNC" = 99999&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;which will not work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while the format I suggested:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;funct_value = 99999
query = "\"FUNC\" = '%s'" % (func_value)
print query&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;will print:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "FUNC" = '99999'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;which is what you need&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The python % formating (specifically, the %s) casts the variable as a string,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;just as str(var) does,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;so you should not have type problems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;alternatly, you could modify your method as so:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;query = '"FUNC" = \'' + str(funct_value) + "'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One trick is that, instead of &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print srow.FUNC&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print query&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;At this point it is the query string you want to inspect, not the field value&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(and you should have been printing funct_value anyway, that is what you are trying to use)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;finally&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your error messege clearly shows that it gets to the ExportToPDF before bailing,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but I suspect it bails because there is nothing for it to export.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You could try cutting out all the fancy StreetLayer.definitionQuery&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;stuff, and making sure it will export anything at all...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:51:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/populating-a-python-list-and-queue-empty-error/m-p/749879#M57927</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2021-12-12T07:51:42Z</dc:date>
    </item>
  </channel>
</rss>

