If it is a text you do not need datetime module.
Read the dates and replace '/' with "".
Read the dates and replace '/' with "".
>>> line = "2018/01/02" >>> line.replace('/', '') '20180102'