<?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: Select records by number of spaces in field in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288691#M69134</link>
    <description>&lt;P&gt;If you have OccupantLastName field, subtract that from the OccupantLabel to get OccupantFirstName. Assuming that for 'John "Joe" Van Smith Jr', the OccupantLastName is 'Van Smith Jr'....&lt;/P&gt;</description>
    <pubDate>Fri, 12 May 2023 18:10:22 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2023-05-12T18:10:22Z</dc:date>
    <item>
      <title>Select records by number of spaces in field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288636#M69120</link>
      <description>&lt;P&gt;I have a graves hosted feature layer that has Ownerfullname, Firstname, lastname, OccupantLabel, OccupantFirstName,&amp;nbsp;OccupantLastName.&amp;nbsp; Somewhere down the line some of the Ownerfirstname was placed in the OccupantFirstName which is different from the OccupantLabel.&amp;nbsp; I cannot use a simple strip from the end of the string due to multiple last names and suffixes.&amp;nbsp; I am looking for a way to select records from the&amp;nbsp;OccupantLabel field by the number of spaces and haven't found a way.&amp;nbsp; The field has been trimmed to remove any leading or ending spaces.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the following ways in the select by records window just to find 1 space:&lt;/P&gt;&lt;P&gt;OccupantLabel.Count(" ") = 1&lt;/P&gt;&lt;P&gt;OccupantLabel.Count(' ') = 1&lt;/P&gt;&lt;PRE&gt;(LEN(column1 &lt;SPAN class=""&gt;+&lt;/SPAN&gt; &lt;SPAN class=""&gt;';'&lt;/SPAN&gt;)&lt;SPAN class=""&gt;-&lt;/SPAN&gt;LEN(REPLACE(column1,&lt;SPAN class=""&gt;' '&lt;/SPAN&gt;,&lt;SPAN class=""&gt;''&lt;/SPAN&gt;)) =&amp;nbsp;1)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;OccupantLabel like '%" "%'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be apprciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 16:11:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288636#M69120</guid>
      <dc:creator>Ona_Tim</dc:creator>
      <dc:date>2023-05-12T16:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Select records by number of spaces in field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288647#M69123</link>
      <description>&lt;P&gt;If I understand correctly, you're trying to remove 2 spaces from records, such that "BOB&amp;nbsp; SMITH" (2 spaces between BOB and SMITH) would be "BOB SMITH". Is that correct?&lt;/P&gt;&lt;P&gt;If so, I have used Find and Replace within the attribute table in ArcGIS Pro to Find: &amp;lt;space bar x2&amp;gt; and Replace: &amp;lt;space bar x1&amp;gt;. No brackets or quotes are needed. You can test is first by just finding a record and verifying it's what you're looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you're wanting to find where a first name has been , could you construct a variable by concatenating the occupant Firstname + " " + lastname and then checking that against the OccupantLabel to see which records don't match?&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 16:33:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288647#M69123</guid>
      <dc:creator>bbaker_tngeo</dc:creator>
      <dc:date>2023-05-12T16:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select records by number of spaces in field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288657#M69125</link>
      <description>&lt;P&gt;Nope.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following example&lt;/P&gt;&lt;P&gt;OccupantLablel&amp;nbsp; &amp;nbsp;OccupantFirstName(Exisiting)&amp;nbsp;&amp;nbsp;OccupantFirstName(What I need)&lt;/P&gt;&lt;P&gt;John Smith&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;Alice&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; John&lt;/P&gt;&lt;P&gt;John J Smith&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; John&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; John J&lt;/P&gt;&lt;P&gt;John "Joe"&amp;nbsp; Van Smith Jr&amp;nbsp; &amp;nbsp; &amp;nbsp;Joe&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; John "Joe"&lt;/P&gt;&lt;P&gt;I am try to select records so I only select John Smith (one space) so I can strip the correct first name or select by 2 spaces in the case of&amp;nbsp;John J Smith and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 16:52:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288657#M69125</guid>
      <dc:creator>Ona_Tim</dc:creator>
      <dc:date>2023-05-12T16:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Select records by number of spaces in field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288667#M69127</link>
      <description>&lt;P&gt;Calculate Field, Python.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;splitString = yourString.split()
oneSpace = splitString[0] + " " + splitString[1]&lt;/LI-CODE&gt;&lt;P&gt;note - edited original post to use .split() default whitespace method which would be more robust than .split(" ") which would include &amp;gt;=2 consecutive whitespaces.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 18:29:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288667#M69127</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2023-05-12T18:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: Select records by number of spaces in field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288674#M69129</link>
      <description>&lt;P&gt;That would work for John J Smith but not for John Smith.&amp;nbsp;&lt;/P&gt;&lt;P&gt;As John Smith would need to be&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;splitstring = yourstring.split(" ")&lt;/P&gt;&lt;P&gt;onespace = splitstring[0]&lt;/P&gt;&lt;P&gt;That is why I need to select the records base on the number of spaces before Calculating them.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 17:33:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288674#M69129</guid>
      <dc:creator>Ona_Tim</dc:creator>
      <dc:date>2023-05-12T17:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select records by number of spaces in field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288691#M69134</link>
      <description>&lt;P&gt;If you have OccupantLastName field, subtract that from the OccupantLabel to get OccupantFirstName. Assuming that for 'John "Joe" Van Smith Jr', the OccupantLastName is 'Van Smith Jr'....&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 18:10:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288691#M69134</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-05-12T18:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Select records by number of spaces in field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288701#M69135</link>
      <description>&lt;P&gt;splitString would be a list which looks like this&lt;/P&gt;&lt;LI-CODE lang="c"&gt;['John', 'Smith']&lt;/LI-CODE&gt;&lt;P&gt;splitString[0] would only return the first item 'John'.&amp;nbsp; The code should work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 18:20:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1288701#M69135</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2023-05-12T18:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Select records by number of spaces in field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1289176#M69179</link>
      <description>&lt;P&gt;With leading/trailing spaces already stripped:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;&amp;gt;&amp;gt;&amp;gt; s = 'John Smith'
&amp;gt;&amp;gt;&amp;gt; splitString = s.split(" ")
&amp;gt;&amp;gt;&amp;gt; splitString
['John', 'Smith']
&amp;gt;&amp;gt;&amp;gt; len(splitString)
2
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt; s = 'John J Smith'
&amp;gt;&amp;gt;&amp;gt; splitString = s.split(" ")
&amp;gt;&amp;gt;&amp;gt; splitString
['John', 'J', 'Smith']
&amp;gt;&amp;gt;&amp;gt; len(splitString)
3
&amp;gt;&amp;gt;&amp;gt; &lt;/LI-CODE&gt;&lt;P&gt;You can also iterate through the split string and count the number of 'spaces'.&amp;nbsp; this would be more robust if there could be more than one space in between owner names:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;numSpaces = 0
for splstr in splitString:
	if splstr == '' or splstr is None:
		numSpaces +=1
print(numSpaces)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can split the string by " " (space) and then see the length of the resultant string.&amp;nbsp; Won't really help if there are multiple spaces in a row, but the len() will let you know if there is more than two components to the name.&lt;/P&gt;&lt;P&gt;Not sure if it works for you, but at least a coule ideas of "counting" spaces in the strings.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 15:28:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1289176#M69179</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2023-05-15T15:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: Select records by number of spaces in field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1289211#M69181</link>
      <description>&lt;P&gt;Thank you Ken! That was it.&amp;nbsp; I used&amp;nbsp; OccupantFirstname = !OccupantLabel!.rstrip(!OccupantLastName!)&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 16:40:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/select-records-by-number-of-spaces-in-field/m-p/1289211#M69181</guid>
      <dc:creator>Ona_Tim</dc:creator>
      <dc:date>2023-05-15T16:40:18Z</dc:date>
    </item>
  </channel>
</rss>

