title: awk rearrange columns in a csv file
body: <p>I have a csv file that has the data with 5 columns and i need to rearrange the columns to make the athlete column come first and then all the other columns here is the original csv file named Final.csv</p>
  
  <p><em>I pasted the output from libreoffice so this output has no commas and seem like a tsv file but it is a csv file</em></p>
  
  <pre><code>Trialtime   type    Track   time    Athlete
  20170101 07:15:00   Warmup  ABC 85.2    Jon
  20170101 07:45:00   Sprint1 ABC 59.44   Jon
  20170101 08:30:00   TRIAL   ABC 57.21   Jon
  20170101 08:00:00   Warmup  ABC 120.51  Bill
  20170101 08:40:05   Sprint1 ABC 61.35   Bill
  20170101 09:15:00   Sprint2 ABC 60.08   Bill
  20170101 10:30:00   TRIAL   ABC 60.37   Bill
  20170101 07:15:00   Warmup  ABC 85.2    Jon
  20170101 07:45:00   Sprint1 ABC 59.44   Jon
  20170101 08:30:00   TRIAL   ABC 57.21   Jon
  20170101 08:00:00   Warmup  ABC 120.51  Bill
  20170101 08:40:05   Sprint1 ABC 61.35   Bill
  20170101 09:15:00   Sprint2 ABC 60.08   Bill
  20170101 10:30:00   TRIAL   ABC 60.37   Bill
  </code></pre>
  
  <p><strong>and i want to make the athelete coulmn first aso i use this awk command</strong></p>
  
  <pre><code>awk -F, '{print $5,$1,$2,$3,$4}' OFS=, Final.csv &gt; add.csv
  </code></pre>
  
  <p><strong>It rearranges the coulmns alright but make the data garbled like this</strong></p>
  
  <p>as you can see there is somehow a extra field is coming on top and making the data unusable </p>
  
  <pre><code>Athlete             
      Trialtime   type    Track   time
  Jon             
      20170101 07:15:00   Warmup  ABC 85.2
  Jon             
      20170101 07:45:00   Sprint1 ABC 59.44
  Jon             
      20170101 08:30:00   TRIAL   ABC 57.21
  Bill                
      20170101 08:00:00   Warmup  ABC 120.51
  Bill                
      20170101 08:40:05   Sprint1 ABC 61.35
  Bill                
      20170101 09:15:00   Sprint2 ABC 60.08
  Bill                
      20170101 10:30:00   TRIAL   ABC 60.37
  </code></pre>
  
  <p>i have no earthly idea what is going wrong here i have been at it for around 4 hours now, i think i am doing everything right but why the extra space comes ?   </p>