<?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 using a web service to populate sparse data in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-a-web-service-to-populate-sparse-data/m-p/591233#M46347</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am nothing but a wee baby when it comes to python, know some ultra-simple things to make repetitive tasks faster. But I need some help and googling hasn't gotten me any really usable results yet.&amp;nbsp; Probably I'm just not using the right vocabulary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I frequently have to go through piles and piles of sparse data and fill in missing values.&amp;nbsp; Generally this requires querying over the web using a known value or two.&amp;nbsp; This query service has a REST endpoint and would be a good candidate for automating, I think.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone has any snippets of code that would:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Take a value from a particular field in a feature class (say, EVENT ID)&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Send that value as an argument to a base URL (for example, &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://www.some_gis_service.com/lookup/" rel="nofollow" target="_blank"&gt;http://www.some_gis_service.com/lookup/&lt;/A&gt;&lt;SPAN&gt;&amp;lt;EVENT ID value extracted from field&amp;gt;/details)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;Look through the XML return and find a particular tag (for example, &amp;lt;DATE&amp;gt;2014-01-01T03:00:00&amp;lt;/DATE&amp;gt;)&lt;/LI&gt;&lt;LI&gt;update a field with that value (or some parsing thereof)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this make sense?&amp;nbsp; I'd probably want to build in some sort of dependency or pause between calls so that I don't overwhelm the server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help!&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Feb 2015 11:57:40 GMT</pubDate>
    <dc:creator>EricEagle</dc:creator>
    <dc:date>2015-02-06T11:57:40Z</dc:date>
    <item>
      <title>using a web service to populate sparse data</title>
      <link>https://community.esri.com/t5/python-questions/using-a-web-service-to-populate-sparse-data/m-p/591233#M46347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am nothing but a wee baby when it comes to python, know some ultra-simple things to make repetitive tasks faster. But I need some help and googling hasn't gotten me any really usable results yet.&amp;nbsp; Probably I'm just not using the right vocabulary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I frequently have to go through piles and piles of sparse data and fill in missing values.&amp;nbsp; Generally this requires querying over the web using a known value or two.&amp;nbsp; This query service has a REST endpoint and would be a good candidate for automating, I think.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone has any snippets of code that would:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Take a value from a particular field in a feature class (say, EVENT ID)&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Send that value as an argument to a base URL (for example, &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://www.some_gis_service.com/lookup/" rel="nofollow" target="_blank"&gt;http://www.some_gis_service.com/lookup/&lt;/A&gt;&lt;SPAN&gt;&amp;lt;EVENT ID value extracted from field&amp;gt;/details)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;Look through the XML return and find a particular tag (for example, &amp;lt;DATE&amp;gt;2014-01-01T03:00:00&amp;lt;/DATE&amp;gt;)&lt;/LI&gt;&lt;LI&gt;update a field with that value (or some parsing thereof)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this make sense?&amp;nbsp; I'd probably want to build in some sort of dependency or pause between calls so that I don't overwhelm the server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help!&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 11:57:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-web-service-to-populate-sparse-data/m-p/591233#M46347</guid>
      <dc:creator>EricEagle</dc:creator>
      <dc:date>2015-02-06T11:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: using a web service to populate sparse data</title>
      <link>https://community.esri.com/t5/python-questions/using-a-web-service-to-populate-sparse-data/m-p/591234#M46348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Python for REST.&lt;/P&gt;&lt;P&gt;My blog explains the code in detail here: &lt;A href="https://paulcrickard.wordpress.com/2015/01/13/esri-rest-and-python-pandas-dataframe/" title="https://paulcrickard.wordpress.com/2015/01/13/esri-rest-and-python-pandas-dataframe/"&gt;ESRI REST and Python: pandas.DataFrame | Architecture and Planning&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #666666; font-family: Georgia, Times, serif; font-size: 16px; font-style: italic;"&gt;import urllib, urllib2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #666666; font-style: italic; font-size: 16px; font-family: Georgia, Times, serif;"&gt;import simplejson&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #666666; font-family: Georgia, Times, serif; font-size: 16px; font-style: italic;"&gt;param = {‘where':’1=1′,’outFields':’*’,’f':’json’}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #666666; font-family: Georgia, Times, serif; font-size: 16px; font-style: italic;"&gt;url = ‘&lt;/SPAN&gt;&lt;A href="http://coagisweb.cabq.gov/%E2%80%A6/APD_Incidents/MapServer/0/query" rel="nofollow" style="font-size: 16px; color: #17517b; font-family: Georgia, Times, serif; font-style: italic; background: #ffffff;"&gt;http://coagisweb.cabq.gov/…/APD_Incidents/MapServer/0/query&lt;/A&gt;&lt;SPAN style="color: #666666; font-family: Georgia, Times, serif; font-size: 16px; font-style: italic;"&gt; ?’ + urllib.urlencode(param)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #666666; font-family: Georgia, Times, serif; font-size: 16px; font-style: italic;"&gt;rawreply = urllib2.urlopen(url).read()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #666666; font-family: Georgia, Times, serif; font-size: 16px; font-style: italic;"&gt;reply = simplejson.loads(rawreply)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #666666; font-family: Georgia, Times, serif; font-size: 16px; font-style: italic;"&gt;print reply[“features”][0][“attributes”][“date”]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #666666; font-family: Georgia, Times, serif; font-size: 16px; font-style: italic;"&gt;print reply[“features”][0][“attributes”][“CVINC_TYPE”]&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 15:12:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-web-service-to-populate-sparse-data/m-p/591234#M46348</guid>
      <dc:creator>PaulCrickard</dc:creator>
      <dc:date>2015-02-06T15:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: using a web service to populate sparse data</title>
      <link>https://community.esri.com/t5/python-questions/using-a-web-service-to-populate-sparse-data/m-p/591235#M46349</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;If you want some python examples of how to extract features from a REST end point using python, you can find some in this thread: &lt;A href="https://community.esri.com/message/450145"&gt;Re: Extract Features From MapServer/ Rest/ Soap/ etc?&lt;/A&gt;&amp;nbsp; Jake Skinner created a toolbox to do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;There are also references to some python code I wrote to do this:&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;the simple way:&lt;A _jive_internal="true" href="https://community.esri.com/thread/118781#445348‌" title="https://community.esri.com/thread/118781#445348‌"&gt;https://community.esri.com/thread/118781#445348‌&lt;/A&gt; &lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;or using a little more advanced:&lt;A _jive_internal="true" href="https://community.esri.com/thread/118781#445572" title="https://community.esri.com/thread/118781#445572"&gt;https://community.esri.com/thread/118781#445572&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;You can find an example of updating a feature service through Python and REST here:&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;A href="https://community.esri.com/message/447121"&gt;Re: UpdateFeature REST API Python Script Unexpected Error&lt;/A&gt;‌&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Filip Kral mentions an interesting &lt;A href="https://community.esri.com/message/394827"&gt;Python client for ArcGIS for Server&lt;/A&gt; and this post (&lt;A href="https://community.esri.com/docs/DOC-2981"&gt;Loading ArcGIS REST Service data into Excel&lt;/A&gt; ) by Marc Hoogerwerf is worth reading too.&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 18:41:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-web-service-to-populate-sparse-data/m-p/591235#M46349</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-02-06T18:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: using a web service to populate sparse data</title>
      <link>https://community.esri.com/t5/python-questions/using-a-web-service-to-populate-sparse-data/m-p/591236#M46350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Xander!&amp;nbsp; Since reading this I have a script now that uses a dictionary to store results and then query that first before going out and hitting the service.&amp;nbsp; Thanks for the links,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 09:54:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-web-service-to-populate-sparse-data/m-p/591236#M46350</guid>
      <dc:creator>EricEagle</dc:creator>
      <dc:date>2015-02-19T09:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: using a web service to populate sparse data</title>
      <link>https://community.esri.com/t5/python-questions/using-a-web-service-to-populate-sparse-data/m-p/591237#M46351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds good! If you are willing to share this with the community it would be great.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 11:47:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-web-service-to-populate-sparse-data/m-p/591237#M46351</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-02-19T11:47:54Z</dc:date>
    </item>
  </channel>
</rss>

