<?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: Dynamic segmentation with respect to a control factor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531908#M41643</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are all of the the "Item ID" values unique in the source table?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 May 2015 21:31:25 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2015-05-07T21:31:25Z</dc:date>
    <item>
      <title>Dynamic segmentation with respect to a control factor</title>
      <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531907#M41642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Is there a way either with python scripts or other solution to dynamically segment the following table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Input table (not a feature class)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="192"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="64"&gt;Item ID&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;Begin &lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;End&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;1001&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;1002&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;1003&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;1004&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Each segmented section (from-to) should have all the item numbers written to a field that is within a certain range. From the input table, the final table should look like the one below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Output table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="334"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="64"&gt;Begin &lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;End&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;Item ID&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="142"&gt;Item ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;0&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;1001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;1001&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;1001; 1002&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;1002&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;1001; 1002; 1004&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;4&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;1003&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;1001; 1002; 1003; 1004&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;5&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;7&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;1004&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;1002&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 15:51:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531907#M41642</guid>
      <dc:creator>ChukwuemekaEzeiruaku</dc:creator>
      <dc:date>2015-05-07T15:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic segmentation with respect to a control factor</title>
      <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531908#M41643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are all of the the "Item ID" values unique in the source table?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 21:31:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531908#M41643</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-05-07T21:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic segmentation with respect to a control factor</title>
      <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531909#M41644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, they are all unique&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 21:33:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531909#M41644</guid>
      <dc:creator>ChukwuemekaEzeiruaku</dc:creator>
      <dc:date>2015-05-07T21:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic segmentation with respect to a control factor</title>
      <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531910#M41645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the output table, how did you get a Begin range value of 5 when there was no Begin value of 5 in the input table?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 21:56:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531910#M41645</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-05-07T21:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic segmentation with respect to a control factor</title>
      <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531911#M41646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;there's an end value of 5 which the next range starts from.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 22:00:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531911#M41646</guid>
      <dc:creator>ChukwuemekaEzeiruaku</dc:creator>
      <dc:date>2015-05-07T22:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic segmentation with respect to a control factor</title>
      <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531912#M41647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So it's kind of like this?&lt;/P&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1004__________
&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; 1003_____
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1002______________________________
1001_________________________
1000_____
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the segment from 0 to 1 includes items 1000, 1001&lt;/P&gt;&lt;P&gt;1 to 2 includes items 1001, 1002&lt;/P&gt;&lt;P&gt;2 to 3 includes items 1001, 1002&lt;/P&gt;&lt;P&gt;3 to 4 includes items 1001, 1002, 1004&lt;/P&gt;&lt;P&gt;4 to 5 includes items 1001, 1002, 1003, 1004&lt;/P&gt;&lt;P&gt;5 to 6 includes items 1002&lt;/P&gt;&lt;P&gt;6 to 7 includes items 1002&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it looks like you dissolve the segments that have the same items. So 1-2 and 2-3 become 1-3? Same with 5-6 and 6-7 becoming 5-7?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:08:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531912#M41647</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-11T23:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic segmentation with respect to a control factor</title>
      <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531913#M41648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ooops, the output table should look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="290"&gt;&lt;TBODY&gt;&lt;TR style="font-weight: inherit; font-style: inherit;"&gt;&lt;TD class="xl63" height="20" style="font-style: inherit;" width="64"&gt;Begin&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none; font-style: inherit;" width="64"&gt;End&lt;/TD&gt;&lt;TD class="xl64" style="border-left: none; font-style: inherit;" width="162"&gt;Item ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-weight: inherit; font-style: inherit;"&gt;&lt;TD class="xl63" height="20" style="border-top: none; font-style: inherit;" width="64"&gt;0&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none; font-style: inherit;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none; font-style: inherit;"&gt;1001&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-weight: inherit; font-style: inherit;"&gt;&lt;TD class="xl63" height="20" style="border-top: none; font-style: inherit;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none; font-style: inherit;" width="64"&gt;3&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none; font-style: inherit;"&gt;1001; 1002&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-weight: inherit; font-style: inherit;"&gt;&lt;TD class="xl63" height="20" style="border-top: none; font-style: inherit;" width="64"&gt;3&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none; font-style: inherit;" width="64"&gt;4&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none; font-style: inherit;"&gt;1001; 1002; 1004&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-weight: inherit; font-style: inherit;"&gt;&lt;TD class="xl63" height="20" style="border-top: none; font-style: inherit;" width="64"&gt;4&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none; font-style: inherit;" width="64"&gt;5&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none; font-style: inherit;"&gt;1001; 1002; 1003; 1004&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-weight: inherit; font-style: inherit;"&gt;&lt;TD class="xl63" height="20" style="border-top: none; font-style: inherit;" width="64"&gt;5&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none; font-style: inherit;" width="64"&gt;7&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none; font-style: inherit;"&gt;&lt;P&gt;1002&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Sorry about that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 23:12:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531913#M41648</guid>
      <dc:creator>ChukwuemekaEzeiruaku</dc:creator>
      <dc:date>2015-05-07T23:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic segmentation with respect to a control factor</title>
      <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531914#M41649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tested it with your sample data, but I don't know how well it will work with more a more complex dataset. Note that the output field that lists all of the ItemID values has to have a limit, which I arbitrarily set to 255. Of course, you'll also need to change the paths and names accordingly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy
&amp;nbsp;&amp;nbsp;&amp;nbsp; import os

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Local variables
&amp;nbsp;&amp;nbsp;&amp;nbsp; mygdb = r"N:\TechTemp\BlakeT\Work\TEMP.gdb"
&amp;nbsp;&amp;nbsp;&amp;nbsp; mytable = os.path.join(mygdb, "SegmentSequence")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Read input table into dictionary
&amp;nbsp;&amp;nbsp;&amp;nbsp; itemsdict = {}
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(mytable, ["ItemID", "Begin", "End"]) as s_cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for item, begin, end in s_cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemsdict[item] = (begin, end)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Identify segments
&amp;nbsp;&amp;nbsp;&amp;nbsp; allsegments = [i[0] for i in itemsdict.values()] + [i[1] for i in itemsdict.values()]
&amp;nbsp;&amp;nbsp;&amp;nbsp; segments = tuple(sorted(set(allsegments)))
&amp;nbsp;&amp;nbsp;&amp;nbsp; del allsegments

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create output table
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateTable_management(mygdb, "SegmentSequence_output")
&amp;nbsp;&amp;nbsp;&amp;nbsp; mytable_out = os.path.join(mygdb, "SegmentSequence_output")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(mytable_out, "Begin", "SHORT")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(mytable_out, "End", "SHORT")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(mytable_out, "SegmentItems", "TEXT", field_length=255)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Write segment items to output table
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.InsertCursor(mytable_out, ["Begin", "End", "SegmentItems"]) as i_cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for enum, seg in enumerate(segments):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&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; begin = seg
&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; end = segments[enum + 1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except IndexError:
&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; break
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; seg_items = [k for k, v in itemsdict.items() if v[0] &amp;lt;= begin and v[1] &amp;gt;= end]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = (begin, end, str(seg_items).strip('[]'))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i_cursor.insertRow(row)


if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:08:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531914#M41649</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-11T23:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic segmentation with respect to a control factor</title>
      <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531915#M41650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;this is awesome Blake, i will test it and get back to you.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 00:01:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531915#M41650</guid>
      <dc:creator>ChukwuemekaEzeiruaku</dc:creator>
      <dc:date>2015-05-08T00:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic segmentation with respect to a control factor</title>
      <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531916#M41651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep, &lt;A href="https://community.esri.com/migrated-users/48550" target="_blank"&gt;Blake T&lt;/A&gt; answer is the correct one. I did a test and it yields the correct result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thought it was fun so I tried something too. See code below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy
&amp;nbsp;&amp;nbsp;&amp;nbsp; import numpy

&amp;nbsp;&amp;nbsp;&amp;nbsp; tbl_in = r'C:\Forum\TableFun\data.gdb\tbl158276'
&amp;nbsp;&amp;nbsp;&amp;nbsp; tbl_out = r'C:\Forum\TableFun\data.gdb\tbl158276_out'
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct = {r[0]:(r[1], r[2]) for r in arcpy.da.SearchCursor(tbl_in, ('Item_ID', 'Begin_', 'End_'))}
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_tot = list(set([v[0] for v in dct.values()] + [v[1] for v in dct.values()]))

&amp;nbsp;&amp;nbsp;&amp;nbsp; dct_ranges = {}
&amp;nbsp;&amp;nbsp;&amp;nbsp; for i in range(len(lst_tot)-1):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; key_range = (lst_tot&lt;I&gt;, lst_tot[i+1])&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dct_ranges[key_range] = []
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for key, tpl_range in sorted(dct.items()):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if isInRange(tpl_range[0], tpl_range[1], key_range):
&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; dct_ranges[key_range].append(key)

&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_numpy = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; for k, v in sorted(dct_ranges.items()):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_numpy.append((k[0], k[1], ",".join([str(i) for i in v])))

&amp;nbsp;&amp;nbsp;&amp;nbsp; array = numpy.array(lst_numpy,
&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; numpy.dtype([('Begin', numpy.int32),
&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;&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; ('End', numpy.int32),
&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;&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; ('Item_ID', numpy.str_, 255)]))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.da.NumPyArrayToTable(array, tbl_out)

def isInRange(begin, end, key_range):
&amp;nbsp;&amp;nbsp;&amp;nbsp; return key_range[0] &amp;lt; end and key_range[1] &amp;gt; begin

if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:08:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531916#M41651</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T23:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic segmentation with respect to a control factor</title>
      <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531917#M41652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I knew there had to be a numpy solution too; unfortunately, I know squat about it. I also like your dictionary comprehension line with the search cursor better than mine. Thanks for posting, &lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;&amp;nbsp; &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 13:12:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531917#M41652</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-05-08T13:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic segmentation with respect to a control factor</title>
      <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531918#M41653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Blake, your solution worked but i got an error from line 37 as shown in the image.&lt;IMG alt="Capture.JPG" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/96369_Capture.JPG" style="width: 620px; height: 294px;" /&gt;&lt;/P&gt;&lt;P&gt;Also i got a table with half the records from the input table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 14:31:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531918#M41653</guid>
      <dc:creator>ChukwuemekaEzeiruaku</dc:creator>
      <dc:date>2015-05-08T14:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic segmentation with respect to a control factor</title>
      <link>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531919#M41654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have marked this question as answered and branched the additional question to a new thread:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/158653"&gt;Re: Dynamic segmentation with respect to a control factor Additional Requirements&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 20:23:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/dynamic-segmentation-with-respect-to-a-control/m-p/531919#M41654</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-05-08T20:23:16Z</dc:date>
    </item>
  </channel>
</rss>

