title: Handle modifications in a diff file
body: <p>I've got a diff file and I want to handle adds/deletions/modifications to update an SQL database.</p>
  
  <pre><code>+NameA|InfoA1|InfoA2
  -NameB|InfoB1|InfoB2
  +NameB|InfoB3|InfoB2
  -NameC|InfoC1|InfoC2
  -NameD|InfoD1|InfoD2
  -NameE|InfoE1|InfoE2
  +NameD|InfoD1|InfoD3
  +NameE|InfoE3|InfoE2
  </code></pre>
  
  <p>With a Python script, I first detect two following lines with a regular expressions to handle modifications like B.</p>
  
  <pre><code>re.compile(r"^-(.+?)\|(.*?)\|(.+?)\n\+(.+?)\|(.*?)\|(.+?)(?:\n|\Z)", re.MULTILINE)
  </code></pre>
  
  <p>I delete all the matching lines, and then rescan my file and then handle all of them like additions/deletions.
  My problem is with lines like D &amp; E. For the moment I treat them like two deletions, then two additions, and I've got consequences of CASCADE DELETE in my SQL database, as I should treat them as modifications.</p>
  
  <p>How can I handle such modifications D &amp; E?</p>
  
  <p>The diff file is generated by a bash script before, I could handle it differently if needed.</p>