title: Editing a lines in a csv file based on previous lines
body: <p>Im very very new to python, I'm using it here as Im told it's good for fileIO.</p>
  
  <p>I have a CSV file in the following format. It records the daily activity for my staff.</p>
  
  <hr>
  
  <p>Date, Name, Project, Manager</p>
  
  <p>01/01/10, Tommy, HyperDyne, Joe Bloggs</p>
  
  <p>01/01/10, Sue, Robot, Joe Bloggs</p>
  
  <p>01/01/10, Mark, HyperDyne, Joe Bloggs</p>
  
  <p>02/01/10, Tommy, SICK, </p>
  
  <p>03/01/10, Tommy, HyperDyne, Joe Bloggs</p>
  
  <hr>
  
  <p>When an employee is marked as SICK, the manager field is always blank. I want to fill in the Manager field with the previous manager entry for that employee. I want to fill in all the blanks in the csv, and put in NULLS when we cannot say.</p>
  
  <p>In pseudocode-ish:</p>
  
  <pre><code>Forall lines n
  if n.Project = "Sick"
    y = 1
    if n-y.name = n.name
        n.manager = n-y.manager
    else y++
    if y &gt; n
        n.manager = null
  </code></pre>
  
  <p>(could probably wrap that into a for y &lt; n loop perhaps)</p>
  
  <p>This would need to be either edit the input file, or output a new file. I suspect editing the input file would be easier, as people can be sick multiple days in a row.</p>
  
  <p>Would love some advice, its been ages since Ive done procedural programming</p>