Writing to a csv file in a customized way using scrapy
I'd like to mention, that there is a special way of making output files in scrapy - item pipelines. So, in order to make it right, you should write your own pipeline (or modify standard one via subclassing).

Also, you does not close the file, once you're done and you keep it open most of the time. The both problems are handled nicely with pipelines. 

UPD: Well, you've asked for a better way, there it is. Although, if it's not acceptable for some hard-to-explain reasons (it's understandable), here's the other approach, how to make it better. 


Don't leave the file open. There is a method (__del__()) which destroys the spider object. Add the code to close the file before it. 
Another one is to store only the filename in the variable and open / close the file each time you write into it. 
Another option is to use NoSQL database, which does not need to be opened / closed. And after scraping is done - get the output file from it. 
If you have a few values to scrape you can store it in object variable, and then export it before __del__() method. 


All the ways above are NOT welcomed by the actual developer community and may lead to serious problem in future. Use them carefully. Sometimes it's easier (in the long run) to read and understand how it really should be done. 

Maybe it's the exact case?