title: parsing data tagged with ANSI color escape sequences
body: <p>need help with converting a log file with data tagged with ANSI color escape sequences and date time stamps. Here is the format for lines in the text:</p>
  
  <pre><code>'\x1b[34m[SOME_INFO]\x1b[0m \x1b[36m[SOME_OTHR_INFO]\x1b[0m Thu Sep 09 00:59:12 XST some variable length message which might contain commas (,), etc.'
  </code></pre>
  
  <p>I am on an isolated network with almost no access to Internet and using Python 2.7. </p>
  
  <p>I have wasted a few hours :(. The closest I got to is using @Elliot Chance's solution</p>
  
  <pre><code>re.sub(r'\x1b\[[\d;]+m', '', s)
  </code></pre>
  
  <p>provided here <a href="https://stackoverflow.com/questions/13506033/filtering-out-ansi-escape-sequences">Filtering out ANSI escape sequences</a> as follows:</p>
  
  <pre><code>t = re.sub(r'\x1b\[[\d;]+m', '~', s)
  re.split(r'~|(Mon|Tue|Wed|Thu|Fri|Sat|Sun.*?\d{4})', t)
  </code></pre>
  
  <p>which doesn't give me what I want. 
  The output from above code:</p>
  
  <pre><code>['',
   None,
   '[SOME_INFO]',
   None,
   ' ',
   None,
   '[SOME_OTHR_INFO]',
   None,
   ' ',
   'Thu',
   ' Sep 09 00:59:12 XST some variable length message which might contain commas (,), etc.']
  </code></pre>
  
  <p>The output I am looking for is as follows:</p>
  
  <pre><code>'SOME_INFO, SOME_OTHR_INFO, Thu Sep 09 00:59:12 XST, some variable length message which might contain commas (,), etc.
  </code></pre>
  
  <p>Is there a way to load the data to a pandas dataframe using <code>pandas.read_csv()</code> or similar? </p>
  
  <p>Note: Every line starts with an escape code but there could be variable fields in each line (i.e., 
  <code>SOME_INFO, SOME_OTHR_INFO, ANOTHER_INFO, etc. followed by the timestamp followed by free text).</code></p>