<?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 Extract values to the left of a certain character in a string in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/extract-values-to-the-left-of-a-certain-character/m-p/250962#M19323</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I received a table of data, and in that table is a field with latitude and longitude coordinates in one field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An example is:&amp;nbsp;45.4000/-122.700&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I added two fields, latitude and longitude.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Using field calculator I can successfully&amp;nbsp;extract values after the '/' into the longitude field so that it is populated only with&amp;nbsp;&lt;SPAN&gt;-122.700.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The expression is:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;!Latitude_Longitude!&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;!Latitude_Longitude!&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;rindex&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'/'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am not able to extract the values for latitude so that the latitude field will be populated just with&amp;nbsp;&lt;SPAN&gt;45.4000. I can also not perform this by using an exact number of characters, as the table of coordinates can have anywhere from 2 to 5 decimal places. Any help on how to extract all values to the left of the '/' would be appreciated.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 May 2018 22:49:56 GMT</pubDate>
    <dc:creator>Brian_McLeer</dc:creator>
    <dc:date>2018-05-09T22:49:56Z</dc:date>
    <item>
      <title>Extract values to the left of a certain character in a string</title>
      <link>https://community.esri.com/t5/python-questions/extract-values-to-the-left-of-a-certain-character/m-p/250962#M19323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I received a table of data, and in that table is a field with latitude and longitude coordinates in one field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An example is:&amp;nbsp;45.4000/-122.700&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I added two fields, latitude and longitude.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Using field calculator I can successfully&amp;nbsp;extract values after the '/' into the longitude field so that it is populated only with&amp;nbsp;&lt;SPAN&gt;-122.700.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The expression is:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;!Latitude_Longitude!&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;!Latitude_Longitude!&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;rindex&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'/'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am not able to extract the values for latitude so that the latitude field will be populated just with&amp;nbsp;&lt;SPAN&gt;45.4000. I can also not perform this by using an exact number of characters, as the table of coordinates can have anywhere from 2 to 5 decimal places. Any help on how to extract all values to the left of the '/' would be appreciated.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 May 2018 22:49:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extract-values-to-the-left-of-a-certain-character/m-p/250962#M19323</guid>
      <dc:creator>Brian_McLeer</dc:creator>
      <dc:date>2018-05-09T22:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Extract values to the left of a certain character in a string</title>
      <link>https://community.esri.com/t5/python-questions/extract-values-to-the-left-of-a-certain-character/m-p/250963#M19324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The easiest way is to use a split() function with the split character. Switch to the python interpreter first. Because they are strings, convert them to floats as well.&lt;/P&gt;&lt;P&gt;!latitude! = float(!field!.split('/')[0]) for the left side&lt;/P&gt;&lt;P&gt;!longitude' = float(!field!.split('/')[1]) for the right side&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 May 2018 23:11:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extract-values-to-the-left-of-a-certain-character/m-p/250963#M19324</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2018-05-09T23:11:16Z</dc:date>
    </item>
  </channel>
</rss>

