Hello all,<br><br> I have a csv file (from a previous code output). It looks like this:<br>Species2, Protein ID, E_value, Length, Hit From, Hit to, Protein ID2, Locus Tag, Start/Stop, Species<br>Streptomyces sp. AA4, ZP_05482482, 2.8293600000000001e-140, 5256, 1824, 2249\n, ZP_05482482, StAA4_0101000304844, complement(NZ_ACEV01000078.1:25146..40916)4, Streptomyces sp. AA4: 0\n<br>
Streptomyces sp. AA4, ZP_05482482, 8.0333299999999997e-138, 5256, 123, 547\n, ZP_05482482, StAA4_0101000304844, complement(NZ_ACEV01000078.1:25146..40916)4, Streptomyces sp. AA4: 0\n<br>Streptomyces sp. AA4, ZP_05482482, 1.08889e-124, 5256, 3539, 3956\n, ZP_05482482, StAA4_0101000304844, complement(NZ_ACEV01000078.1:25146..40916)4, Streptomyces sp. AA4: 0\n<br>
....<br><br>I want to removing certain sections in each line so I wrote this code using csv.DictWriter:<br>import csv<br>data = csv.DictReader(open('strep_aa.txt'))<br><br>for x in data:<br> del x['Species2']<br>
del x[' Protein ID2']<br> print x<br><br> When it prints to the screen everything works great:<br>{' Hit From': ' 1824', ' Hit to': ' 2249\\n', ' Protein ID': ' ZP_05482482', ' Locus Tag': ' StAA4_0101000304844', ' Start/Stop': ' complement(NZ_ACEV01000078.1:25146..40916)4', ' Species': ' Streptomyces sp. AA4: 0\\n', ' Length': ' 5256', ' E_value': ' 2.8293600000000001e-140'}<br>
{' Hit From': ' 123', ' Hit to': ' 547\\n', ' Protein ID': ' ZP_05482482', ' Locus Tag': ' StAA4_0101000304844', ' Start/Stop': ' complement(NZ_ACEV01000078.1:25146..40916)4', ' Species': ' Streptomyces sp. AA4: 0\\n', ' Length': ' 5256', ' E_value': ' 8.0333299999999997e-138'}<br>
<br clear="all">What I don't know how to do is the export this back out a csv file and rearrange each key as a column header so it work look like this:<br>Species Protein ID E Value .....<br><br>I thought csv.DictWriter would be the way to go since it writes dictionaries to text files. I was wondering how do I go about doing this? I don't really understand the syntax.<br>
<br>Thank you!<br><br>Ara<br><br><br>-- <br>Quis hic locus, quae regio, quae mundi plaga. Ubi sum. Sub ortu solis an sub cardine glacialis ursae.<br>