title: Convert table of row-based records to column-based records (CSV)
body: <p>Given a table in a text file that contains row based data, what method would you recommend for converting to a column based table? (e.g. CSV).</p>
  
  <p>Input_data.txt:</p>
  
  <pre><code>Source =         X:\folder_abc
  Destination =    Y:\Abc_folder
  Total bytes =    208,731,021
  MB per min =     256.5
  Source =         X:\folder_def
  Destination =    Y:\xyz_folder
  Total bytes =    123,134,545
  MB per min =     326
  Source =         X:\folder_foo
  Destination =    Y:\Baz_folder
  Total bytes =    24,344
  MB per min =     532
  ...etc.
  </code></pre>
  
  <p>Desired Result (only formatted with tabs here for legibility):</p>
  
  <pre><code>Source,             Destination,        Total bytes,    MB per min
  "X:\folder_abc",    "Y:\Abc_folder",    "208,731,021",  "256.5"
  "X:\folder_def",    "Y:\xyz_folder",    "123,134,545",  "326"
  "X:\folder_foo",    "Y:\Baz_folder",    "24,344",       "532"
  ...
  </code></pre>
  
  <p>Tools at my disposal are Windows batch files and Powershell. Prefer a .bat solution because I'm more comfortable there, but if that is too circuitous or opaque we can punt it.</p>
  
  <p><em>UPDATE, as per comments</em></p>
  
  <p>I've figured out how to turn the records into <em>name</em> &amp; <em>value</em> variables, but don't know how to manipulate them from that point to transpose into columns.</p>
  
  <pre><code>for /f "tokens=1,2 delims==" %%a in ('findstr /c:"=" "%logfile%"') do (
    @echo %%a %%b
    )
  </code></pre>
  
  <p>It just occured to me I can do one column per text file and then append them all in Excel. Crude but workable perhaps(?)</p>
  
  <pre><code>for /f "tokens=1,2 delims==" %%a in ('findstr /c:"=" "%logfile%"') do (
    @echo %%b &gt;&gt;  %%a.csv
    )
  </code></pre>
  
  <p><em>UPDATE-2:</em> quote all values in desired result, as dbenham pointed out not doing so will cause problems.</p>