title: Transpose the rows and columns in a csv file efficiently in c# WPF
body: <p>Trying to transpose the rows and columns. Is there a better way to do this?
  Also without having to create an additional file and delete it later on.</p>
  <pre><code>StreamReader sr = new StreamReader(Path.Combine(Path.GetDirectoryName(output), &quot;1&quot; + &quot;.csv&quot;));
                  int rowno = 0;
                  string[] csvValues = null;
                  string[] headerNames = null;
                  while (!sr.EndOfStream)
                  {
                     string csvRowData = sr.ReadLine().Trim();
                     csvValues = csvRowData.Split(';');
                     if (rowno == 0)
                      {
                          headerNames = csvValues;
                         rowno++;
                      }
                    else
                   {
                       for (int j = 0; j &lt; csvValues.Length; j++)
                       {
  
                          string Column2 = csvValues[j];
  
                          for (int i = j; i &lt; csvValues.Length; i++)
                          {
                              string Column1 = headerNames[i];
  
                              string csvtranspose = string.Join(&quot;;&quot;, Column1, Column2, 
  </code></pre>
  <p>Environment.NewLine);</p>
  <pre><code>                            using (StreamWriter wr = new StreamWriter(output, true))
                              {
                                  wr.Write(csvtranspose);
  
                              }
  
                              break;
                          }
                          if (j == 6)
                              break;
                      }
                      break;
                  }
  
              }
              sr.Dispose();
              File.Delete(Path.Combine(Path.GetDirectoryName(output), &quot;1&quot; + &quot;.csv&quot;));
  </code></pre>