reorder columns of a csv file containing float, interger and text data?
<p>I would like to do a similar process to a csv file as detailed in <a href="http://stackoverflow.com/questions/6117868/write-csv-columns-out-in-a-different-order-in-python">this question</a>, but I get an error message saying:  </p>

<pre><code>TypeError: list indices must be integers 
</code></pre>

<p>The csv file that I want to rearrange has a combination of float, text, and interger data types.  I'm assuming this is the problem, but can't figure out a way to modify the code below to insert the data.  It writes the header information in the new CSV file though.</p>

<p>I'm using the same code as suggested by John Machin, but my write names varaible uses: </p>

<pre><code>writenames = "ID,average,max,min,median,mode,stddev,skewness,kurtosis".split(",")
reader = csv.reader(open("/home/usrs/chris/Summary.csv", "rb"))
writer = csv.writer(open("/home/usrs/chris/SummaryNEW.csv", "wb"))
readnames = reader.next()
names2indicies = dict((name,index) for index, name in enumerate(readnames))
writeindices = [names2string[name] for name in writenames]
reorderfunct = operator.itemgetter(writeindices)
writer.writerow(writenames)
for row in reader:
    writer.writerow(reorderfunct(row))
</code></pre>
