<?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: Publish csv to feature using python - Date field  in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866632#M4448</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you sure something didn't change in the formatting of the CSV?&amp;nbsp; Could the date field used to have quotes around it and now it doesn't?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 May 2020 21:28:09 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2020-05-29T21:28:09Z</dc:date>
    <item>
      <title>Publish csv to feature using python - Date field</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866631#M4447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All for the past 8 weeks i have been running a script that populates workforce with assignments from a csv published as a feature to ArcGIS online using python&amp;nbsp; it worked every day until today when i was met with an error.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;strptime() argument 1 must be str, not int Failed to execute (Add Assignments)&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;from datetime import datetime


#Append updated information
assignments = []
for feature in features:
    assignments.append(
        workforce.Assignment(
            project,
            geometry=feature.geometry,
            location=feature.attributes["location"],
            due_date=datetime.strptime(feature.attributes["Due_Date"], '%d/%m/%Y %H:%M:%S'),
            description=feature.attributes["description"],
            priority=2,
            assignment_type=feature.attributes["AssignmentTXT"],
            status="unassigned",
            work_order_id=feature.attributes["WorkOrderReference"]
        )
    )
    
project.assignments.batch_add(assignments)&lt;SPAN class=""&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the error is relating to the date field, i have changed nothing in my script. i uploaded the csv to Arcgis online published it as a feature and then used it to populate the assignments. Prior to this the due date was always recognized as a string but today Arcgis online recognized it as a date. Why would this suddenly start happening has something change with the way a csv is published to Arcgis online. i know i can just use the date field now but i am just curious as to why all of a sudden it changed.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:47:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866631#M4447</guid>
      <dc:creator>PaulSweeney3</dc:creator>
      <dc:date>2021-12-12T10:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Publish csv to feature using python - Date field</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866632#M4448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you sure something didn't change in the formatting of the CSV?&amp;nbsp; Could the date field used to have quotes around it and now it doesn't?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 May 2020 21:28:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866632#M4448</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-05-29T21:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: Publish csv to feature using python - Date field</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866633#M4449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;to fix I would just wrap the due date in a string function. &lt;/P&gt;&lt;PRE class=""&gt;&lt;CODE&gt;str(feature.attributes["Due_Date"])&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 May 2020 22:48:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866633#M4449</guid>
      <dc:creator>ClayDonaldsonSWCA</dc:creator>
      <dc:date>2020-05-29T22:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Publish csv to feature using python - Date field</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866634#M4450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joshua/Clay&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for your response. the issue seems to be intermittant sometimes its a date sometimes a string.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No they did not have quotes around them .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clay do you think will this work for both scenarios i.e the field type is a string or a date format. The date format would be a unix timestamp.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jun 2020 09:58:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866634#M4450</guid>
      <dc:creator>PaulSweeney3</dc:creator>
      <dc:date>2020-06-03T09:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Publish csv to feature using python - Date field</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866635#M4451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think &lt;A href="https://community.esri.com/migrated-users/311366"&gt;Clay Donaldson&lt;/A&gt;‌'s suggestion is the best path forward.&amp;nbsp; In terms of whether it will work, no better way to find out then trying it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In terms of why it is read as a date sometimes and a string other times, I am still going back to the program creating the CSV. How is the CSV file being created?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It could be the file is being read differently between different Python versions.&amp;nbsp; Are you running the code on the same machine or on different machines with Python 2.x on some machines and Python 3.x on others.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jun 2020 13:46:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866635#M4451</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-06-03T13:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Publish csv to feature using python - Date field</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866636#M4452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joshua&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried it with the string function and this time the script returned a date as opposed to yesterday where it returned a string and it failed with the following error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in terms of python versions&amp;nbsp; i wrote the code in jupyter notebook and i am running it in arcgis pro but as far as i can see they are both python 3.&amp;nbsp; Is there a particular module in pro that may be acting differently?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/495307_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/495371_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jun 2020 19:46:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866636#M4452</guid>
      <dc:creator>PaulSweeney3</dc:creator>
      <dc:date>2020-06-03T19:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: Publish csv to feature using python - Date field</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866637#M4453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was more concerned about a Python 2/3 issue than Jupyter/Pro.&amp;nbsp; That said, if it consistently gives different results when run in the two environments, then something is definitely different.&amp;nbsp; Are the results the same when run repeatedly from the same environment?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jun 2020 19:54:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866637#M4453</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-06-03T19:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Publish csv to feature using python - Date field</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866638#M4454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;They were the same for several weeks it worked fine in both .&amp;nbsp; I did have a cloned environment in arcgis pro that i was using, which i removed. Would that have caused an issue .&amp;nbsp;&amp;nbsp;My current solution is&amp;nbsp;adding&amp;nbsp; an additional string field and calculating&amp;nbsp; the date into it ,&amp;nbsp; i am now using that&amp;nbsp; to update the Assignment which seems to work consistently.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2020 13:25:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/publish-csv-to-feature-using-python-date-field/m-p/866638#M4454</guid>
      <dc:creator>PaulSweeney3</dc:creator>
      <dc:date>2020-06-10T13:25:38Z</dc:date>
    </item>
  </channel>
</rss>

