title: Using Python to randomize csv file
body: <p>I have a csv file with 2 columns:</p>
  <pre class="lang-none prettyprint-override"><code>1 A
  2 B
  3 C
  4 D
  </code></pre>
  <p>My aim is to use Python to open the file, read it, randomize the order of the two lists (i.e. have 1 be with the same line as C, 2 with D etc.), and then save the new randomized lists in a different csv file.</p>
  <p>I read some more stuff about writer, but am unsure how to use these functions yet.</p>
  <p>The only problem is that I need to keep the columns headers intact, they can't be randomized. The code was as follows:</p>
  <pre><code>import csv
  import random
  
  with open (&quot;my_file&quot;) as f:
      l = list(csv.reader(f))
  
  random.shuffle(l)
  
  with open(&quot;random.csv&quot;, &quot;W&quot;) as f:
      csv.writer(f).writerows(f)
  </code></pre>