Format date string in a file using Python
<p>I get csv files from my client which contains variable number of columns. Out of these columns there can be some columns containing date string but the order is not defined, for example :</p>

<pre><code>column1str|column2dt|column3str|column4int|column5int|column6dt
ab c1|10/20/2010|1234|10.02|530.55|30-01-2011
ab c2|10/10/2010|12346|11.03|531|05-05-2012
abc3|10/10/2010|122|12|532.44|11-09-2008
abc4|10/11/2010|110|13|533|01-11-2013
abc5|10/10/2010|11111|14|534|30-02-2012
</code></pre>

<p>I get the format of date string from client as input, in the above input there are two formats of date string <code>MM/dd/yyyy</code> and <code>dd-MM-yyyy</code>. </p>

<p>I want to convert all the dates in a particular format <code>dd-MM-yyyyTHH:mmZ</code> in the file itself. I know how to convert date string to desired date string when the input date format is given. The challenge I am facing here is how can I replace the date string at particular column in the file.</p>

<p>try this:</p>

<pre><code>import pandas as pd
data=pd.read_csv('so.txt',delimiter='|',parse_dates=['column2dt','column6dt'])
</code></pre>

python datetime