title: Language PDF: How to add the example sentences to source word and add to CSV
body: <p>First of all, I’m new to Python, so please bear with me.
  I have a PDF file with Spanish vocabulary on the left and the German translation on the right. Sometimes there are also a few example sentences to show how the sentence is used. Here’s how the PDF looks like:</p>
  <p><a href="https://i.stack.imgur.com/WIKZc.png" rel="nofollow noreferrer">Example of PDF</a></p>
  <p>I want to write a Python script, which takes all the vocabulary, the translation and the example sentences (+ the translation) and get a CSV file with four columns. This is how the CSV file should look like:</p>
  <p><a href="https://i.stack.imgur.com/HiaqN.png" rel="nofollow noreferrer">Example of ideal CSV</a></p>
  <p>I can read line by line, which works fine, if there are no example sentences. If there’s an example sentence, however, the line looks somewhat like this:</p>
  <pre><code>Für Senioren gibt es bei   Hay descuentos en los viajes
  Reisen Ermässigung.   para la tercera edad.
  </code></pre>
  <p>The Spanish sentence should look like this: <code>Hay descuentos en los viajes para la tercera edad.</code>
  The German sentence should look like this: <code>Für Senioren gibt es bei Reisen Ermässigung.</code>
  Ideally, the two example sentences should be added to the &quot;base&quot; word, so to &quot;la tercera edad&quot; / &quot;die Senioren&quot; in my example above. For &quot;la tercera edad&quot;, there should be four columns. Sometimes, there are no example sentences; in that case, I just need two columns.</p>
  <p>Here's what I've done:</p>
  <pre><code>import pdfplumber
  
  pdf = pdfplumber.open('spanish.pdf')
  page = pdf.pages[23]
  text = page.extract_text()
  
  # Read each line
  for line in text.split('\n'):
      print(line)
  </code></pre>
  <p>Printing <code>line</code> outputs amongst others the following:</p>
  <pre><code>Für Senioren gibt es bei   Hay descuentos en los viajes
  Reisen Ermässigung.   para la tercera edad.
  </code></pre>
  <p>Maybe there's a way to do it with <code>tabuly-py</code>? I'd appreciate any help.</p>
  <p>Cheers.</p>