title: Python to csv column break
body: <p>I am parsing +1000 txt (Edgar) files with Python and need to transfer some fields into a .csv file. I require 4 fields: file form, file date, company name, and central index key (i.e. firm identification number). To do so, I wrote:</p>
  
  <pre><code>with open('exemptionss1.csv', 'w') as out_file:
      wr = csv.writer(out_file)
      wr.writerow(["file_form", "filedate", "coname", "cik"])  # Headlines in  top row
      for i in range(0, len(exemptions), 4):
          wr.writerow(exemptions[i: i + 4]) 
  </code></pre>
  
  <p>where "exemptions" is the vector variable where all parsed information is. Took it from Sublime Text's result panel: </p>
  
  <pre><code>exemptions = ['S-1', '20090820', '\t\t\t\tDOLLAR GENERAL CORP', '\t\t0000029534', 'S-1/A', '20021114', '\t\t\t\tCONSTAR INTERNATIONAL INC', '\t\t0000029806', '\t\t\t\tCONSTAR FOREIGN HOLDINGS INC', '\t\t0001178543', '\t\t\t\tCONSTAR PLASTICS LLC', '\t\t0001178541', '\t\t\t\tDT INC', '\t\t0001178539', '\t\t\t\tBFF INC', '\t\t0001178538', '\t\t\t\tCONSTAR INC', '\t\t0001178537', 'S-1', '20020523', '\t\t\t\tCONSTAR INTERNATIONAL INC', '\t\t0000029806', 'S-1', '20051123', '\t\t\t\tEXCO RESOURCES INC', '\t\t0000316300', 'S-1', '20061221', '\t\t\t\tEXCO RESOURCES INC', '\t\t0000316300', 'S-1/A', '20140327', '\t\t\t\tAlly Financial Inc.', '\t\t0000040729', 'S-1', '20110331', '\t\t\t\tAlly Financial Inc.', '\t\t0000040729', 'S-1', '20040319', '\t\t\t\tDIGIRAD CORP', '\t\t0000707388', 'S-1', '20040408', '\t\t\t\tBUCYRUS INTERNATIONAL INC', '\t\t0000740761', 'S-1', '20041027', '\t\t\t\tBUCYRUS INTERNATIONAL INC', '\t\t0000740761', 'S-1', '20050630', '\t\t\t\tSEALY CORP', '\t\t0000748015', 'S-1', '20140512', '\t\t\t\tCITIZENS FINANCIAL GROUP INC/RI', '\t\t0000759944']
  </code></pre>
  
  <p>If every .txt file would only contain each field one time, the above would work (it essentially asks python to create a new row every 4 "instances"). However, that is not the case, and a sample of the .csv output file looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/xwZjO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xwZjO.png" alt="enter image description here"></a></p>
  
  <p>As you can see, row 1 is just fine. The problem is in the second .txt file that contains several repetitions of the fields I require and, correctly after 4 instances, it starts a new row. It's not until row 6 (counting the headers) that the new file_form ("S-1") appears again.</p>
  
  <p>What I would like is that every file would be the starting of each .csv row. Importantly, the file form field (I only have "S-1" or "S-1/A" forms) never gets repeated. In other words, the second .txt S-1/A file should include all variables in the same row, and leave row 3 with the next .txt file. Something like this: </p>
  
  <p><a href="https://i.stack.imgur.com/fs55J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fs55J.png" alt="enter image description here"></a></p>
  
  <p>Any suggestions? Thanks a lot in advance.</p>