Add quotation at start and end of every other line ignoring empty line
<p>I need help on organizing texts. I have the list of thousands vocabs in csv. There are term, definition, and sample sentence for each word. Term and definition is separated by the tab and sample sentence is separated by an empty line.</p>

<p>For example:</p>

<pre><code>exacerbate  worsen

This attack will exacerbate the already tense relations between the two communities

exasperate  irritate, vex

he often exasperates his mother with pranks

execrable   very bad, abominable, utterly detestable

an execrable performance
</code></pre>

<p>I want to organize this so that the sample sentence is enclosed by double quotation marks, has no empty line before and after itself, and the term in sentence is replaced by the hyphen. All that change while keeping the tab after the term, the new line in the beginning of each term, and the only a space between the definition and the example sentence. I need this format for importing it to flashcards web application.</p>

<p>Desired outcome using above example:</p>

<pre><code>exacerbate  worsen "This attack will â the already tense relations between the two communities"
exasperate  irritate, vex "he often â his mother with pranks"
execrable   very bad, abominable, utterly detestable "an â performance"
</code></pre>

<p>I am using Mac. I know basic command lines (including regex) and python, but not enough to figure this out by myself. If you could help me, I am very grateful.</p>

<pre><code>#!/usr/local/bin/python3

import re

with open('yourFile.csv', 'r') as myfile:
    data = myfile.read()    

print(re.sub(r'(^[A-Za-z]+)\t(.+)\n\n(.+)\1[s|ed|es|ing]*(.+)$',r'\1\t\2 "\3-\4"', data, flags = re.MULTILINE))
</code></pre>

<p>Output:</p>

<blockquote>
  <p>exacerbate    worsen "This attack will - the already tense relations between the two communities"</p>
  
  <p>exasperate irritate, vex "he often - his mother with pranks"</p>
  
  <p>execrable  very bad, abominable, utterly detestable "an - performance"</p>
</blockquote>

python regex osx textedit