<?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 Python date wild card in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-date-wild-card/m-p/492323#M38574</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I have the following code that works correctly. However, every once in a while there is a file name that has an "06" instead of an "05" and it breaks the script. Is there a way I can use a wild card for that digit?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;        fileName &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fullFileName&lt;SPAN class="punctuation 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;
        fileNameShort &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fileName&lt;SPAN class="punctuation 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;13&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
        fileDateTime &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; dt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strptime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fileName&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"%m%d%Y_%H05shapefile.zip"&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;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 21:39:46 GMT</pubDate>
    <dc:creator>AndrewL</dc:creator>
    <dc:date>2021-12-11T21:39:46Z</dc:date>
    <item>
      <title>Python date wild card</title>
      <link>https://community.esri.com/t5/python-questions/python-date-wild-card/m-p/492323#M38574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I have the following code that works correctly. However, every once in a while there is a file name that has an "06" instead of an "05" and it breaks the script. Is there a way I can use a wild card for that digit?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;        fileName &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fullFileName&lt;SPAN class="punctuation 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;
        fileNameShort &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fileName&lt;SPAN class="punctuation 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;13&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
        fileDateTime &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; dt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strptime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fileName&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"%m%d%Y_%H05shapefile.zip"&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;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:39:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-date-wild-card/m-p/492323#M38574</guid>
      <dc:creator>AndrewL</dc:creator>
      <dc:date>2021-12-11T21:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python date wild card</title>
      <link>https://community.esri.com/t5/python-questions/python-date-wild-card/m-p/492324#M38575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How you are applying the date format for datetime.strptime is unusual, even if it is working.&amp;nbsp; Typically, the date/time formatting only includes date/time components and not additional text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems you are working with a group of files that have consistent naming, can you provide an example of a file name and what you are trying to get because there might be a better overall approach.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Aug 2019 15:25:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-date-wild-card/m-p/492324#M38575</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-08-12T15:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Python date wild card</title>
      <link>https://community.esri.com/t5/python-questions/python-date-wild-card/m-p/492325#M38576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure. We use the Weather Climate Toolkit (a program from NOAA) to automatically download the zip files every hour. They are named after the date/time they are downloaded. However, recently&amp;nbsp;it sometimes takes more than one minute to download a file which causes it to have an "06" instead of "05." Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;08112019_0005shapefile.zip&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;08112019_0105shapefile.zip&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;08112019_0205shapefile.zip&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Aug 2019 15:36:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-date-wild-card/m-p/492325#M38576</guid>
      <dc:creator>AndrewL</dc:creator>
      <dc:date>2019-08-12T15:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Python date wild card</title>
      <link>https://community.esri.com/t5/python-questions/python-date-wild-card/m-p/492326#M38577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does this work for you?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; datetime
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; 
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; file &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"08112019_0005shapefile.zip"&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; fileDateTime &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strptime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;file&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;13&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"%m%d%Y_%H%M"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; fileDateTime &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fileDateTime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;replace&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;minute&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; fileDateTime
datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;datetime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2019&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;8&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;11&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="line-numbers-rows"&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:39:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-date-wild-card/m-p/492326#M38577</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T21:39:48Z</dc:date>
    </item>
  </channel>
</rss>

