I’m a bit stuck with writing a csv file using the python csv library. I’m using Django to get the information into objects out of a database.
What I have now, works but is not yet complete:
writer.writerow([Itag.Gen_ID if Itag else '',
Itag.Solyc if Itag else '',
Itag.GO_number if Itag else '',
Itag.GO_def if Itag else '',
Itag.Itag_description if Itag else '',
Itag.IPR_Number if Itag else '',
Itag.IPR_Description if Itag else '',
Itag.Trivial_name if Itag else '',
Loci.Locus_symbol if Loci else '',
Loci.Locus_name if Loci else '',])
This writes away the object information into a CSV file if there is a object present.
Now in the next part I Have a Object called Blast,
Blast Has a couple of properties:
Blast.name, Blast.hit, Blast.score
The object Itag has a one on one relation with Loci that’s why it all fits nicely in a row.
Now the Blast object has a many on one relation with Itagand Loci
so 5 Blast hits can have a relation with 1 Itag and Loci Hit.
Now how do I write all the 5 Blast object properties to the same row in the CSV file?
It’s untidy and but the most obvious solution is to append the hits to the line:
Personally I’d rarely, if ever, do it this way. I’d rather have one csv file for
lociand another forblast.