title: How to convert pipe-separated text file to CSV?
body: <p>I have a big text file and i want to convert it into CSV using Python. My data looks like:</p>
  
  <pre><code>var1|var2|var3|tonumber|fromnumber|var|coding|udh|var|circle|var|var|var|var15
  
  898980d1-6e5b-40f2-a313-c30f08bf0fe6|49A5919EB0D04EDE9B6CEB5AF932EAA3|sbs1|919899980898|HITECH|1|1|0|VODAFONE|Delhi|2015-02-21 12:08:51|5|3|RBA/6724R # Kailash Ram Panwar (PL) # Rz-410/13 Flat No-09 Iiird Floor Tkd Extn Delhi - 110019-110019 # Tgt Skt #  #
  </code></pre>
  
  <p>How can I convert this file to CSV? I tried:</p>
  
  <pre><code>In [1]: import csv
  
  In [2]: import pandas as pd
  
  In [3]: piperows = []  
  
  f = open("/home/suri/ValueFirst/MT.txt", "rb")
  
  In [6]: readerpipe = csv.reader(f, delimiter = '|')
  
  In [7]: for row in readerpipe: 
     ...:     piperows.append(row)
     ...:     f.close()  
     ...:  
  </code></pre>
  
  <p>And I got the below error:</p>
  
  <pre><code>----------------------------------------------------
  ValueError                      Traceback (most recent call last)  
  &lt;ipython-input-7-842b0d42f436&gt; in &lt;module&gt;()  
  ----&gt; 1 for row in readerpipe:  
        2     piperows.append(row)  
        3     f.close()  
        4   
  
  ValueError: I/O operation on closed file  
  </code></pre>