title: Bash: transform key-value lines to CSV format
body: <p><sup><strong>Editor's note:</strong> I've clarified the problem definition, because I think the problem is an interesting one, and this question deserves to be reopened.</sup></p>
  
  <p>I've got a text file containing key-value lines in the following format - <em>note that the <code>#</code> lines below are only there to show repeating blocks and are NOT part of the input</em>:</p>
  
  <pre class="lang-none prettyprint-override"><code>Country:United Kingdom
  Language:English
  Capital city:London
  #
  Country:France
  Language:French
  Capital city:Paris
  #
  Country:Germany
  Language:German
  Capital city:Berlin
  #
  Country:Italy
  Language:Italian
  Capital city:Rome
  #
  Country:Russia
  Language:Russian
  Capital city:Moscow
  </code></pre>
  
  <p>Using shell commands and utilities, how can I transform such a file to CSV format, so it will look like this?</p>
  
  <pre class="lang-none prettyprint-override"><code>Country,Language,Capital city
  United Kingdom,English,London
  France,French,Paris
  Germany,German,Berlin
  Italy,Italian,Rome
  Russia,Russian,Moscow
  </code></pre>
  
  <p>In other words:</p>
  
  <ul>
  <li>Make the key names the column names of the CSV header row.</li>
  <li>Make the values from each block a data row each.</li>
  </ul>
  
  <p>[OP's original] Edit: My idea would be to separate the entries e.g. Country:France would become Country France, and then grep/sed the heading. However I have no idea how to move the headings from a single column to several separate ones.</p>