title: How to Pretty Print a CSV file in Python
body: <p>How can I pretty print a CSV file using Python, not any external tool?</p>
  
  <p>For example I have this CSV file:</p>
  
  <pre class="lang-none prettyprint-override"><code>title1|title2|title3|title4
  datalongdata|datalongdata|data|data
  
  data|data|data|datalongdatadatalongdatadatalongdatadatalongdatadatalongdata
  data|data'data|dat
  </code></pre>
  
  <p>I would like to transform it to visually look like a table. For example, to something like that:</p>
  
  <pre class="lang-none prettyprint-override"><code>+ --------------------------------------------------------------------------------------------------- +
  | title1       | title2       | title3 | title4                                                       |
  + --------------------------------------------------------------------------------------------------- +
  | datalongdata | datalongdata | data   | data                                                         |
  |              |              |        |                                                              |
  | data         | data         | data   | datalongdatadatalongdatadatalongdatadatalongdatadatalongdata |
  | data         | data'data    | dat    |                                                              |
  + --------------------------------------------------------------------------------------------------- +
  </code></pre>