title: Resolve Unconverted Data Remains: Error without replace other file contents
body: <p>I am currently writing a script which sorts dates. I have a input file which is called <code>sample.txt</code> and an output file called <code>sample2.txt</code>. At the end the contents of the input file should be sorted and written to the output file. But when running my script I am running into the following error: <code>Unconverted Data Remains: Dentist</code>. It is caused because <code>strptime</code> cannot convert <code>Dentist</code>. So my question is: How I can fix this error without deleting the word Dentist or other none date contents?</p>
  <p>This is the full error message:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;test3.py&quot;, line 156, in &lt;module&gt;
      main_user_input.user_input()
    File &quot;test3.py&quot;, line 144, in user_input
      list_next_appointments.list_next_appointments_main()
    File &quot;test3.py&quot;, line 96, in list_next_appointments_main
      bands = sorted(bands, key=lambda date: datetime.strptime(date, &quot;%d.%m.%Y&quot;))
    File &quot;test3.py&quot;, line 96, in &lt;lambda&gt;
      bands = sorted(bands, key=lambda date: datetime.strptime(date, &quot;%d.%m.%Y&quot;))
    File &quot;/home/supre/anaconda3/lib/python3.8/_strptime.py&quot;, line 568, in _strptime_datetime
      tt, fraction, gmtoff_fraction = _strptime(data_string, format)
    File &quot;/home/supre/anaconda3/lib/python3.8/_strptime.py&quot;, line 352, in _strptime
      raise ValueError(&quot;unconverted data remains: %s&quot; %
  ValueError: unconverted data remains:  Dentist
  </code></pre>
  <p>This is the content of my input file:</p>
  <pre><code>23.08.2021 Dentist 
  13.08.2031 Surgery 
  13.01.2022 Family 
  </code></pre>
  <p>This is my code:</p>
  <pre><code>with open('sample.txt', 'r') as file1, open('sample2.txt','w+') as file2:
      bands = (line.strip() for line in file1)
      bands = sorted(bands, key=lambda date: datetime.strptime(date, &quot;%d.%m.%Y&quot;))
      file2.write(' \n'.join(bands))
  
  </code></pre>
  <p>Thank's for every help and suggestion in advance:)</p>