title: How to convert a text file seperated by a new line to a csv file using python
body: <p>How do i convert a text file seperated by a new line to a csv file.</p>
  
  <p><strong>Text File Sample</strong></p>
  
  <pre><code>/themes/modern/user_style.php?user_colors[bg_color]="&lt;/style&gt;&lt;script&gt;&lt;/script&gt;
  ?&lt;meta http-equiv=set-cookie content="testpokn=7494"&gt;
  /_37040/
  /clr_cream/
  reg_req/
  trackir3pro-1/
  selector_10274/
  javascript/orders.html
  perlutil/
  /carte_ameriques2/
  /javascript/count.conf
  /glow_chairs/
  </code></pre>
  
  <p>I want to convert this AS is to a csv file. 1 column, multiple rows. Each line of the text file should be a row in the csv file.</p>
  
  <p><strong>Python</strong></p>
  
  <pre><code>def loadFile(name):
  
      directory = os.getcwd()
      filepath = directory + "/" + name
      data = open(filepath,'r').readlines()
  
      result = []
      for d in data:
          d = str(urllib.parse.unquote(d))
          result.append(d)
      return result
  
  
  
  def main():
  
      data = loadFile('code.txt')
  
      with open('new.csv', 'w', newline='') as fp:
          a = csv.writer(fp,)
          a.writerows(data)
  
  main()
  </code></pre>
  
  <p>My problem is that for each char it adds a comma</p>