title: Converting 1000 text files into a single csv file
body: <p>I want to convert multiple text files into a single csv file.the text are named as(file1.txt,file2.txt....file1000.txt). A text file(file1.txt) format is as follows:</p>
  
  <pre><code>Employee id: us51243
  Employee name: Mark santosh
  department:engineering
  Age:25 
  </code></pre>
  
  <p>I want the ouput as:</p>
  
  <pre><code>Employee id,Employee name,department,Age
  us51243,Mark santosh,engineering,25//(file1.txt values)
  ...................................//(file2.txt values)
  </code></pre>
  
  <p>But in the ouput I am getting the value of file1000.txt only as follows:</p>
  
  <pre><code>Employee id,Employee name,department,Age
  us98621,Andy Gonzalez,Support &amp; services,25
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>import csv
  import os
  for x in range(1,1001):
      filepath=os.path.normpath('C:\\Text\\file{}.txt'.format(x))
      with open(filepath) as f, open('emp.csv', 'w',newline='') as file:
          writer = csv.writer(file)
          val = zip(*[l.rstrip().split(': ') for l in f])
          writer.writerows(val)
  </code></pre>
  
  <p>Kindly note:Also I want to display the header(Employee id,Employee name,Department,Age) only once</p>